summaryrefslogtreecommitdiffstats
path: root/devtools/shared/css
diff options
context:
space:
mode:
authorJustOff <Off.Just.Off@gmail.com>2019-04-20 13:53:46 +0300
committerJustOff <Off.Just.Off@gmail.com>2019-04-20 13:53:46 +0300
commitd9137b4b7ae446750713c48a48574465301e3699 (patch)
treef9089b1a382b20b797704c0b224afcb93891f538 /devtools/shared/css
parente0116ac2b78eb4e621a4d0769e01f8358a6d661c (diff)
downloadUXP-d9137b4b7ae446750713c48a48574465301e3699.tar
UXP-d9137b4b7ae446750713c48a48574465301e3699.tar.gz
UXP-d9137b4b7ae446750713c48a48574465301e3699.tar.lz
UXP-d9137b4b7ae446750713c48a48574465301e3699.tar.xz
UXP-d9137b4b7ae446750713c48a48574465301e3699.zip
Handle URL token in a closer way to the CSS3 spec
Diffstat (limited to 'devtools/shared/css')
-rw-r--r--devtools/shared/css/lexer.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/devtools/shared/css/lexer.js b/devtools/shared/css/lexer.js
index 9013b63ea..192fa95b3 100644
--- a/devtools/shared/css/lexer.js
+++ b/devtools/shared/css/lexer.js
@@ -1067,6 +1067,7 @@ Scanner.prototype = {
// aToken.mIdent may be "url" at this point; clear that out
aToken.mIdent.length = 0;
+ let hasString = false;
let ch = this.Peek();
// Do we have a string?
if (ch == QUOTATION_MARK || ch == APOSTROPHE) {
@@ -1075,6 +1076,7 @@ Scanner.prototype = {
aToken.mType = eCSSToken_Bad_URL;
return;
}
+ hasString = true;
} else {
// Otherwise, this is the start of a non-quoted url (which may be empty).
aToken.mSymbol = 0;
@@ -1093,6 +1095,25 @@ Scanner.prototype = {
}
} else {
aToken.mType = eCSSToken_Bad_URL;
+ if (!hasString) {
+ // Consume until before the next right parenthesis, which follows
+ // how <bad-url-token> is consumed in CSS Syntax 3 spec.
+ // Note that, we only do this when "url(" is not followed by a
+ // string, because in the spec, "url(" followed by a string is
+ // handled as a url function rather than a <url-token>, so the
+ // rest of content before ")" should be consumed in balance,
+ // which will be done by the parser.
+ // The closing ")" is not consumed here. It is left to the parser
+ // so that the parser can handle both cases.
+ do {
+ if (IsVertSpace(ch)) {
+ this.AdvanceLine();
+ } else {
+ this.Advance();
+ }
+ ch = this.Peek();
+ } while (ch >= 0 && ch != RIGHT_PARENTHESIS);
+ }
}
},