Bug 751939 - make url( followed by EOF valid. r=dbaron

This commit is contained in:
Alexandros Chronopoulos 2014-07-23 00:14:16 +03:00
parent d0cff9196f
commit 7532ad60f8
4 changed files with 13 additions and 10 deletions

View File

@ -3355,7 +3355,8 @@ CSSParserImpl::ParseMozDocumentRule(RuleAppendFunc aAppendFunc, void* aData)
}
NS_ASSERTION(!mHavePushBack, "mustn't have pushback at this point");
if (!mScanner->NextURL(mToken) || mToken.mType != eCSSToken_URL) {
mScanner->NextURL(mToken);
if (mToken.mType != eCSSToken_URL) {
REPORT_UNEXPECTED_TOKEN(PEMozDocRuleNotURI);
SkipUntil(')');
delete urls;

View File

@ -1149,25 +1149,21 @@ nsCSSScanner::AppendImpliedEOFCharacters(EOFCharacters aEOFCharacters,
* Exposed for use by nsCSSParser::ParseMozDocumentRule, which applies
* the special lexical rules for URL tokens in a nonstandard context.
*/
bool
void
nsCSSScanner::NextURL(nsCSSToken& aToken)
{
SkipWhitespace();
int32_t ch = Peek();
if (ch < 0) {
return false;
}
// aToken.mIdent may be "url" at this point; clear that out
aToken.mIdent.Truncate();
int32_t ch = Peek();
// Do we have a string?
if (ch == '"' || ch == '\'') {
ScanString(aToken);
if (MOZ_UNLIKELY(aToken.mType == eCSSToken_Bad_String)) {
aToken.mType = eCSSToken_Bad_URL;
return true;
return;
}
MOZ_ASSERT(aToken.mType == eCSSToken_String, "unexpected token type");
@ -1180,6 +1176,7 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
// Consume trailing whitespace and then look for a close parenthesis.
SkipWhitespace();
ch = Peek();
// ch can be less than zero indicating EOF
if (MOZ_LIKELY(ch < 0 || ch == ')')) {
Advance();
aToken.mType = eCSSToken_URL;
@ -1190,7 +1187,6 @@ nsCSSScanner::NextURL(nsCSSToken& aToken)
mSeenBadToken = true;
aToken.mType = eCSSToken_Bad_URL;
}
return true;
}
/**

View File

@ -234,7 +234,7 @@ class nsCSSScanner {
// which, for historical reasons, must make additional function
// tokens behave like url(). Please do not add new uses to the
// parser.
bool NextURL(nsCSSToken& aTokenResult);
void NextURL(nsCSSToken& aTokenResult);
// This is exposed for use by nsCSSParser::ParsePseudoClassWithNthPairArg,
// because "2n-1" is a single DIMENSION token, and "n-1" is a single

View File

@ -87,6 +87,12 @@ const tests = [
"wHCBYQNDAQAMuALRrGb97AAAAABJRU5ErkJggg=='",
prop: "background-image", pseudo: ""
},
{
name: "url-token 4", /*Bug 751939*/
ref: "#r { background-image: url( )}",
tst: "#t { background-image: url(" ,
prop: "background-image", pseudo: ""
},
{
name: "counter",
ref: "#r::before { content: counter(tr, upper-alpha) }",