You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2019/11/26 23:02:09 UTC

[royale-compiler] branch develop updated: MXMLDataBindingParser: fixed issue where data binding expressions containing strings that start/end with quotes would incorrectly strip out the quotes (closes #49)

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

joshtynjala 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 bc89bba  MXMLDataBindingParser: fixed issue where data binding expressions containing strings that start/end with quotes would incorrectly strip out the quotes (closes #49)
bc89bba is described below

commit bc89bba8061e5f11bb7a7b46c35f232a40e6ec21
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Tue Nov 26 14:49:20 2019 -0800

    MXMLDataBindingParser: fixed issue where data binding expressions containing strings that start/end with quotes would incorrectly strip out the quotes (closes #49)
---
 .../internal/codegen/mxml/royale/MXMLRoyaleEmitter.java     |  9 +--------
 .../compiler/internal/tree/mxml/MXMLDataBindingParser.java  | 13 +++++++++++++
 2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
index baa165a..c97c15f 100644
--- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/mxml/royale/MXMLRoyaleEmitter.java
@@ -1536,14 +1536,7 @@ public class MXMLRoyaleEmitter extends MXMLEmitter implements
                 for (int i = 0; i < n; i++)
                 {
                 	IExpressionNode getterNode = getterNodes.get(i);
-                	if (getterNode.getNodeID() == ASTNodeID.LiteralStringID)
-                	{
-                		sb.append(ASEmitterTokens.DOUBLE_QUOTE.getToken());
-                		sb.append(asEmitter.stringifyNode(getterNode));
-                		sb.append(ASEmitterTokens.DOUBLE_QUOTE.getToken());
-                	}
-                	else
-                		sb.append(asEmitter.stringifyNode(getterNode));
+                    sb.append(asEmitter.stringifyNode(getterNode));
                     if (i < n - 1)
                     	sb.append(ASEmitterTokens.SPACE.getToken() + ASEmitterTokens.PLUS.getToken() + ASEmitterTokens.SPACE.getToken());
                 }
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
index 8a6e45a..5b3e8dc 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLDataBindingParser.java
@@ -340,6 +340,19 @@ class MXMLDataBindingParser
         ISourceFragment[] fragments = fragmentList.toArray(new ISourceFragment[0]);
         String text = SourceFragmentsReader.concatLogicalText(fragments);
 
+        // LiteralNode automatically strips out quote characters at the
+        // beginning and end of the string.
+        // with that in mind, if the original text starts or ends with a quote,
+        // that will get stripped if we don't wrap it manually.
+        // apache/royale-compiler#49
+        if(text.indexOf("\"") != -1)
+        {
+            text = "'" + text + "'";
+        }
+        else
+        {
+            text = "\"" + text + "\"";
+        }
         LiteralNode stringLiteralNode = new LiteralNode(LiteralType.STRING, text);
         stringLiteralNode.setParent(parent);