You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by ah...@apache.org on 2015/07/15 02:55:03 UTC

[5/5] git commit: [flex-falcon] [refs/heads/develop] - handle escapes

handle escapes


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/dc60ca06
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/dc60ca06
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/dc60ca06

Branch: refs/heads/develop
Commit: dc60ca0634fe0e23a8778a76bb9c1b5da57db1b4
Parents: c98ed6e
Author: Alex Harui <ah...@apache.org>
Authored: Tue Jul 14 08:25:04 2015 -0700
Committer: Alex Harui <ah...@apache.org>
Committed: Tue Jul 14 17:54:54 2015 -0700

----------------------------------------------------------------------
 .../internal/css/CSSStringPropertyValue.java    | 36 +++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/dc60ca06/compiler/src/org/apache/flex/compiler/internal/css/CSSStringPropertyValue.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/internal/css/CSSStringPropertyValue.java b/compiler/src/org/apache/flex/compiler/internal/css/CSSStringPropertyValue.java
index 0201357..84531ba 100644
--- a/compiler/src/org/apache/flex/compiler/internal/css/CSSStringPropertyValue.java
+++ b/compiler/src/org/apache/flex/compiler/internal/css/CSSStringPropertyValue.java
@@ -35,7 +35,7 @@ public class CSSStringPropertyValue extends CSSPropertyValue
     {
         super(tree, tokenStream, CSSModelTreeType.PROPERTY_VALUE);
         assert isQuoted(stringWithQuotes) : "Don't strip quotes in parser: [" + stringWithQuotes + "]";
-        this.value = stripQuotes(stringWithQuotes);
+        this.value = convertEscapes(stripQuotes(stringWithQuotes));
     }
 
     private final String value;
@@ -76,4 +76,38 @@ public class CSSStringPropertyValue extends CSSPropertyValue
     {
         return value.substring(1, value.length() - 1);
     }
+    
+    private static String convertEscapes(String value)
+    {
+        int idx = 0;
+        int c = value.indexOf('\\');
+        while (c != -1)
+        {
+            char cnext = value.charAt(c + 1);
+            if (cnext != '\\' && cnext != 'n' && cnext != 't' && cnext != 'r')
+            {
+                int n = value.length() - (c + 1);
+                if (n > 6)
+                    n = 6;
+                StringBuilder sub = new StringBuilder();
+                int i = 0;
+                for (; i < n; i++)
+                {
+                    char cc = value.charAt(c + i + 1);
+                    if (cc != ' ')
+                        sub.append(cc);
+                    else
+                        break;
+                }
+                int ccode = Integer.parseInt(sub.toString(), 16);
+                sub = new StringBuilder();
+                sub.append(Character.toChars(ccode));
+                value = value.substring(0, c) + sub.toString() + value.substring(c + i + 1);
+            }
+            else
+                idx += 2;
+            c = value.indexOf('\\', idx);
+        }
+        return value;
+    }
 }