Bug 1287620 - don't de-quote identifier tokens in parseDeclarations; r?pbro
MozReview-Commit-ID: GecLWyVsNAy
--- 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") {