Bug 1297890 - don't allow token pasting in parseDeclarations; r?pbro
MozReview-Commit-ID: ASs3ldqxMoI
--- a/devtools/client/shared/test/unit/test_parseDeclarations.js
+++ b/devtools/client/shared/test/unit/test_parseDeclarations.js
@@ -348,16 +348,23 @@ const TEST_DATA = [
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]}]
},
+
+ // Regression test for bug 1297890 - don't paste tokens.
+ {
+ parseComments: true,
+ input: "stroke-dasharray: 1/*ThisIsAComment*/2;",
+ expected: [{name: "stroke-dasharray", value: "1 2", priority: "", offsets: [0, 39]}]
+ },
];
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
@@ -362,16 +362,18 @@ function parseDeclarationsInternal(isCss
token.endOffset - 2);
let newDecls = parseCommentDeclarations(isCssPropertyKnown, commentText,
token.startOffset,
token.endOffset);
// Insert the new declarations just before the final element.
let lastDecl = declarations.pop();
declarations = [...declarations, ...newDecls, lastDecl];
+ } else {
+ current += " ";
}
} else {
current += inputString.substring(token.startOffset, token.endOffset);
}
}
// Handle whatever trailing properties or values might still be there
if (current) {