Bug 1287620 - don't de-quote identifier tokens in parseDeclarations; r?pbro draft
authorTom Tromey <tom@tromey.com>
Tue, 19 Jul 2016 12:47:07 -0600
changeset 389650 c46b8f5804b18e99e6a50b51aee41c8bb8b7f4ab
parent 388937 bc547f508f58108db8b9ad9c2b94f130c07de194
child 525813 7d959046ab799b4094496bbdada57290daa25687
push id23473
push userbmo:ttromey@mozilla.com
push dateTue, 19 Jul 2016 18:57:46 +0000
reviewerspbro
bugs1287620
milestone50.0a1
Bug 1287620 - don't de-quote identifier tokens in parseDeclarations; r?pbro MozReview-Commit-ID: GecLWyVsNAy
devtools/client/shared/test/unit/test_parseDeclarations.js
devtools/shared/css-parsing-utils.js
--- a/devtools/client/shared/test/unit/test_parseDeclarations.js
+++ b/devtools/client/shared/test/unit/test_parseDeclarations.js
@@ -341,17 +341,23 @@ const TEST_DATA = [
   },
 
   // Parsing our special comments skips the name-check heuristic.
   {
     parseComments: true,
     input: "/*! walrus: zebra; */",
     expected: [{name: "walrus", value: "zebra", priority: "",
                 offsets: [4, 18], commentOffsets: [0, 21]}]
-  }
+  },
+
+  // Regression test for bug 1287620.
+  {
+    input: "color: blue \\9 no\\_need",
+    expected: [{name: "color", value: "blue \\9 no_need", priority: "", offsets: [0, 23]}]
+  },
 ];
 
 function run_test() {
   run_basic_tests();
   run_comment_tests();
 }
 
 // Test parseDeclarations.
--- a/devtools/shared/css-parsing-utils.js
+++ b/devtools/shared/css-parsing-utils.js
@@ -342,17 +342,19 @@ function parseDeclarationsInternal(isCss
     } else if (token.tokenType === "ident") {
       if (token.text === "important" && hasBang) {
         lastProp.priority = "important";
         hasBang = false;
       } else {
         if (hasBang) {
           current += "!";
         }
-        current += token.text;
+        // Re-escape the token to avoid dequoting problems.
+        // See bug 1287620.
+        current += CSS.escape(token.text);
       }
     } else if (token.tokenType === "symbol" && token.text === "!") {
       hasBang = true;
     } else if (token.tokenType === "whitespace") {
       if (current !== "") {
         current += " ";
       }
     } else if (token.tokenType === "comment") {