Fix parenthesis-matching while parsing format() function in @font-face src: descriptor. (Bug 511333) r=dbaron

This commit is contained in:
Zack Weinberg 2009-08-20 14:52:47 -07:00
parent 325ccb4cf2
commit 6ade4eb7d1
2 changed files with 21 additions and 4 deletions

View File

@ -7957,16 +7957,23 @@ CSSParserImpl::ParseFontSrcFormat(nsTArray<nsCSSValue> & values)
do {
if (!GetToken(PR_TRUE))
return PR_FALSE;
return PR_FALSE; // EOF - no need for SkipUntil
if (mToken.mType != eCSSToken_String)
if (mToken.mType != eCSSToken_String) {
SkipUntil(')');
return PR_FALSE;
}
nsCSSValue cur(mToken.mIdent, eCSSUnit_Font_Format);
values.AppendElement(cur);
} while (ExpectSymbol(',', PR_TRUE));
return ExpectSymbol(')', PR_TRUE);
if (!ExpectSymbol(')', PR_TRUE)) {
SkipUntil(')');
return PR_FALSE;
}
return PR_TRUE;
}
// font-ranges: urange ( ',' urange )*

View File

@ -120,7 +120,7 @@
d: { "src" : "local(\"老鼠\"), url(\"/fonts/Mouse\") format(\"truetype\")" } },
// Correct but unusual src:
{ rule: _("src: local(Hoefler Text);"),
{ rule: _("src: local(Hoefler Text);"),
d: {"src" : "local(\"Hoefler Text\")"}, noncanonical: true },
// Incorrect src:
@ -154,6 +154,16 @@
d: { "src" : "local(\"Mouse\")" },
noncanonical: true },
// Correct parenthesis matching for format()
{ rule: _("src: url(\"/fonts/Mouse\"); " +
"src: url(\"/fonts/Cat\") format(Cat(); src: local(Rat); )"),
d: { "src" : "url(\"/fonts/Mouse\")" },
noncanonical: true },
{ rule: _("src: url(\"/fonts/Mouse\"); " +
"src: url(\"/fonts/Cat\") format(\"Cat\"; src: local(Rat); )"),
d: { "src" : "url(\"/fonts/Mouse\")" },
noncanonical: true },
// unicode-range is not implemented (bug 443976).
// tests for that omitted for now.
];