This is an automated email from the ASF dual-hosted git repository.

aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2843804  quick fix was too quick.  This should fix 
apache/royale-asjs#743
2843804 is described below

commit 284380475a05a659b4d8672ff13fe185b7ba1e28
Author: Alex Harui <[email protected]>
AuthorDate: Tue Mar 3 13:02:38 2020 -0800

    quick fix was too quick.  This should fix apache/royale-asjs#743
---
 .../mxml/royale/MXMLDescriptorSpecifier.java       |   2 +-
 .../mxml/royale/TestRoyaleMXMLApplication.java     | 118 +++++++++++++++++++++
 2 files changed, 119 insertions(+), 1 deletion(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java
index 1260f89..633f642 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLDescriptorSpecifier.java
@@ -237,7 +237,7 @@ public class MXMLDescriptorSpecifier extends 
MXMLNodeSpecifier
                 writeDelimiter(writeNewline);
                 // need to do other escaping here?
                 // restrict="0-9.\"
-                if (value.endsWith("\\'"))
+                if (value.endsWith("\\'") && !value.endsWith("\\\\'"))
                 {
                        value = value.substring(0, value.length() - 1) + "\\'";
                 }
diff --git 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
index e960a52..0a806bf 100644
--- 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
+++ 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/mxml/royale/TestRoyaleMXMLApplication.java
@@ -241,6 +241,124 @@ public class TestRoyaleMXMLApplication extends 
RoyaleTestBase
     }
 
     @Test
+    public void testAlreadyEscapedBackslashStringAttribute()
+    {
+        String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\">"
+                + "<basic:beads><basic:TextPromptBead 
prompt=\"0-9\\\\\"/></basic:beads></basic:Application>";
+
+        IMXMLDocumentNode dnode = (IMXMLDocumentNode) getNode(code,
+                       IMXMLDocumentNode.class, 
RoyaleTestBase.WRAP_LEVEL_NONE);
+
+        
((JSRoyaleEmitter)(mxmlBlockWalker.getASEmitter())).getModel().setCurrentClass(dnode.getDefinition());
+        mxmlBlockWalker.visitDocument(dnode);
+        String appName = dnode.getQualifiedName();
+        String outTemplate = "/**\n" +
+                       " * AppName\n" +
+                       " *\n" +
+                       " * @fileoverview\n" +
+                       " *\n" +
+                       " * @suppress {checkTypes|accessControls}\n" +
+                       " */\n" +
+                       "\n" +
+                       "goog.provide('AppName');\n" +
+                       "\n" +
+                       "goog.require('org.apache.royale.core.Application');\n" 
+
+                       
"goog.require('org.apache.royale.html.accessories.TextPromptBead');\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * @constructor\n" +
+                       " * @extends {org.apache.royale.core.Application}\n" +
+                       " */\n" +
+                       "AppName = function() {\n" +
+                       "  AppName.base(this, 'constructor');\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type 
{org.apache.royale.html.accessories.TextPromptBead}\n" +
+                       "   */\n" +
+                       "  this.$ID0_;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldd;\n" +
+                       "  \n" +
+                       "  /**\n" +
+                       "   * @private\n" +
+                       "   * @type {Array}\n" +
+                       "   */\n" +
+                       "  this.mxmldp;\n" +
+                       "\n" +
+                       "  this.generateMXMLAttributes([\n" +
+                       "    1,\n" +
+                       "    'beads',\n" +
+                       "    null,\n" +
+                       "    [\n" +
+                       "      
org.apache.royale.html.accessories.TextPromptBead,\n" +
+                       "      2,\n" +
+                       "      '_id',\n" +
+                       "      true,\n" +
+                       "      '$ID0',\n" +
+                       "      'prompt',\n" +
+                       "      true,\n" +
+                       "      '0-9\\\\',\n" +
+                       "      0,\n" +
+                       "      0,\n" +
+                       "      null\n" +
+                       "    ],\n" +
+                       "    0,\n" +
+                       "    0\n" +
+                       "  ]);\n" +
+                       "  \n" +
+                       "};\n" +
+                       "goog.inherits(AppName, 
org.apache.royale.core.Application);\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * Prevent renaming of class. Needed for 
reflection.\n" +
+                       " */\n" +
+                       "goog.exportSymbol('AppName', AppName);\n" +
+                       "\n" +
+                       "\n" +
+                               "\n" +
+                       "/**\n" +
+                       " * Metadata\n" +
+                       " *\n" +
+                       " * @type {Object.<string, Array.<Object>>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_CLASS_INFO = { names: [{ 
name: 'AppName', qName: 'AppName', kind: 'class'  }] };\n" +
+                       "\n" +
+                       "\n" +
+                       "\n" +
+                       "/**\n" +
+                       " * Reflection\n" +
+                       " *\n" +
+                       " * @return {Object.<string, Function>}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_REFLECTION_INFO = function () 
{\n" +
+                       "  return {\n" +
+                       "    methods: function () {\n" +
+                       "      return {\n" +
+                               "        'AppName': { type: '', declaredBy: 
'AppName'}\n"+
+                       "      };\n" +
+                       "    }\n" +
+                       "  };\n" +
+                       "};\n" +
+                       "/**\n" +
+                       " * @const\n" +
+                       " * @type {number}\n" +
+                       " */\n" +
+                       "AppName.prototype.ROYALE_COMPILE_FLAGS = 9;\n" +
+                       "\n" +
+                       "\n";
+
+        assertOutWithMetadata(outTemplate.replaceAll("AppName", appName));
+    }
+
+    @Test
     public void testInterfaceAttribute()
     {
         String code = "<basic:Application 
xmlns:fx=\"http://ns.adobe.com/mxml/2009\"; 
xmlns:basic=\"library://ns.apache.org/royale/basic\" 
implements=\"org.apache.royale.core.IChrome\">"

Reply via email to