Bug 748254. When we encounter an unexpected '}' terminating a font-face descriptor's value, correctly close the font-face rule instead of eating the rest of the stylesheet. r=dbaron
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 26 Apr 2012 00:42:00 -0400
changeset 92470 10c3731c3d95623d8a755ed179469b51170929d8
parent 92469 1babdcad0253182a647114cb3e027a3581b665c1
child 92471 2cd647942ca9245d2de6d4d295273ff1b5891c96
push idunknown
push userunknown
push dateunknown
reviewersdbaron
bugs748254
milestone15.0a1
Bug 748254. When we encounter an unexpected '}' terminating a font-face descriptor's value, correctly close the font-face rule instead of eating the rest of the stylesheet. r=dbaron
layout/reftests/css-parsing/invalid-font-face-descriptor-1-ref.html
layout/reftests/css-parsing/invalid-font-face-descriptor-1.html
layout/reftests/css-parsing/reftest.list
layout/style/nsCSSParser.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/invalid-font-face-descriptor-1-ref.html
@@ -0,0 +1,5 @@
+<!DOCTYPE html>
+<style>
+  body { color: green! important; }
+</style>
+There should be no red
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-parsing/invalid-font-face-descriptor-1.html
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<style>
+  body { color: red; }
+  @font-face {
+    src: url(bbb),
+  }
+
+  body { color: green! important; }
+</style>
+There should be no red
--- a/layout/reftests/css-parsing/reftest.list
+++ b/layout/reftests/css-parsing/reftest.list
@@ -1,6 +1,7 @@
 == at-rule-013.html at-rule-013-ref.html
 == invalid-url-handling.xhtml invalid-url-handling-ref.xhtml
 == pseudo-elements-1.html pseudo-elements-1-ref.html
 == invalid-attr-1.html invalid-attr-1-ref.html
 == at-rule-error-handling-import-1.html at-rule-error-handling-ref.html
 == at-rule-error-handling-media-1.html at-rule-error-handling-ref.html
+== invalid-font-face-descriptor-1.html invalid-font-face-descriptor-1-ref.html
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -8212,16 +8212,18 @@ CSSParserImpl::ParseFontSrc(nsCSSValue& 
 
       font.EnumerateFamilies(ExtractFirstFamily, (void*) &dat);
       if (!dat.mGood)
         return false;
 
       cur.SetStringValue(dat.mFamilyName, eCSSUnit_Local_Font);
       values.AppendElement(cur);
     } else {
+      // We don't know what to do with this token; unget it and error out
+      UngetToken();
       return false;
     }
 
     if (!ExpectSymbol(',', true))
       break;
   }
 
   if (values.Length() == 0)