summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-07-31 23:30:59 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-07-31 23:30:59 +0000
commitb3a1829bf335a174f3cf799c919d4007c0bfaacb (patch)
tree670543ceacc62f43a1fe1e164ff8c4b789ae44c6
parent28be213e85e38dbdce658ebafca449e18c974dbd (diff)
downloadlibcss-b3a1829bf335a174f3cf799c919d4007c0bfaacb.tar.gz
libcss-b3a1829bf335a174f3cf799c919d4007c0bfaacb.tar.bz2
Fix at-rule processing.
Fix malformed selector input to actually result in a terminated block. svn path=/trunk/libcss/; revision=4848
-rw-r--r--src/parse/parse.c12
-rw-r--r--test/data/css/blocks.css4
-rw-r--r--test/data/css/malformed.css6
3 files changed, 14 insertions, 8 deletions
diff --git a/src/parse/parse.c b/src/parse/parse.c
index 10575b9..6e10ffc 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -917,9 +917,6 @@ css_error parseAtRule(css_parser *parser)
switch (state->substate) {
case Initial:
-#if !defined(NDEBUG) && defined(DEBUG_EVENTS)
- printf("Begin at-rule\n");
-#endif
parserutils_vector_clear(parser->tokens);
error = getToken(parser, &token);
@@ -955,10 +952,6 @@ css_error parseAtRule(css_parser *parser)
if (error != CSS_OK)
return error;
- error = pushBack(parser, token);
- if (error != CSS_OK)
- return error;
-
/* Grammar ambiguity: any0 can be followed by '{',';',')',']'.
* at-rule can only be followed by '{' and ';'. */
if (token->type == CSS_TOKEN_CHAR && token->data.len == 1) {
@@ -971,6 +964,10 @@ css_error parseAtRule(css_parser *parser)
}
}
+ error = pushBack(parser, token);
+ if (error != CSS_OK)
+ return error;
+
break;
}
@@ -993,6 +990,7 @@ css_error parseAtRuleEnd(css_parser *parser)
switch (state->substate) {
case Initial:
#if !defined(NDEBUG) && defined(DEBUG_EVENTS)
+ printf("Begin at-rule\n");
parserutils_vector_dump(parser->tokens, __func__, tprinter);
#endif
if (parser->event != NULL) {
diff --git a/test/data/css/blocks.css b/test/data/css/blocks.css
index 9ecd720..57be2ee 100644
--- a/test/data/css/blocks.css
+++ b/test/data/css/blocks.css
@@ -2,6 +2,10 @@
@import "simple.css";
+@foo rgb(255,255,255);
+
+@bar (a,b,c);
+
@media screen
{
body { background-color: green; }
diff --git a/test/data/css/malformed.css b/test/data/css/malformed.css
index e1b6af9..cfcbb23 100644
--- a/test/data/css/malformed.css
+++ b/test/data/css/malformed.css
@@ -6,7 +6,11 @@ p { color:red; color:; color:green } /* same with expected recovery */
p { color:green; color{;color:maroon} } /* unexpected tokens { } */
p { color:red; color{;color:maroon}; color:green } /* same with recovery */
+@blah <!-- ;
+@foo --> { moose }
+
"Foo bar baz
-p ( { ) color: green }
+p ( { ) color: green } )
p {color:green}
+p { color: green; }