Author: jmb
Date: Fri Jan 23 18:40:56 2009
New Revision: 6213

URL: http://source.netsurf-browser.org?rev=6213&view=rev
Log:
Fix assertion failure when EOF is encountered in block-content.
Fix assertion failure when the first token within a ruleset isn't an IDENT.

Modified:
    trunk/libcss/src/parse/parse.c

Modified: trunk/libcss/src/parse/parse.c
URL: 
http://source.netsurf-browser.org/trunk/libcss/src/parse/parse.c?rev=6213&r1=6212&r2=6213&view=diff
==============================================================================
--- trunk/libcss/src/parse/parse.c (original)
+++ trunk/libcss/src/parse/parse.c Fri Jan 23 18:40:56 2009
@@ -950,7 +950,13 @@
                if (error != CSS_OK)
                        return error;
 
-               if (token->type == CSS_TOKEN_IDENT) {
+               /* If this can't possibly be the start of a decl-list, then
+                * attempt to parse a declaration. This will catch any invalid
+                * input at this point and read to the start of the next
+                * declaration. FIRST(decl-list) = (';', '}') */
+               if (token->type != CSS_TOKEN_CHAR || token->ilower->len != 1 ||
+                               (token->ilower->data[0] != '}' &&
+                               token->ilower->data[0] != ';')) {
                        parser_state to = { sDeclaration, Initial };
                        parser_state subsequent = { sRulesetEnd, DeclList };
 
@@ -1194,6 +1200,9 @@
                error = getToken(parser, &token);
                if (error != CSS_OK)
                        return error;
+
+               if (token->type == CSS_TOKEN_EOF)
+                       break;
 
                if (token->type != CSS_TOKEN_CHAR || token->ilower->len != 1 ||
                                token->ilower->data[0] != '}') {
@@ -1381,6 +1390,14 @@
                return transition(parser, to, subsequent);
        }
        case Colon:
+               if (parser->parseError) {
+                       parser_state to = { sMalformedDecl, Initial };
+
+                       parser->parseError = false;
+
+                       return transitionNoRet(parser, to);
+               }
+
                error = getToken(parser, &token);
                if (error != CSS_OK)
                        return error;
@@ -1452,7 +1469,9 @@
                if (token->type == CSS_TOKEN_EOF)
                        return done(parser);
 
-               if (token->type != CSS_TOKEN_CHAR || token->ilower->len != 1) {
+               if (token->type != CSS_TOKEN_CHAR || token->ilower->len != 1 ||
+                               (token->ilower->data[0] != '}' && 
+                               token->ilower->data[0] != ';')) {
                        /* Should never happen */
                        assert(0 && "Expected ; or  }");
                }
@@ -1463,11 +1482,9 @@
                                return error;
 
                        return done(parser);
-               } else if (token->ilower->data[0] == ';') {
+               } else {
+                       /* ; */
                        state->substate = WS;
-               } else {
-                       /* Should never happen */
-                       assert(0 && "Expected ; or }");
                }
 
                /* Fall through */


_______________________________________________
netsurf-commits mailing list
[email protected]
http://vlists.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to