Gitweb links:
...log
http://git.netsurf-browser.org/libcss.git/shortlog/54ddec960162bb055b7dc50b1314763fbf763b60
...commit
http://git.netsurf-browser.org/libcss.git/commit/54ddec960162bb055b7dc50b1314763fbf763b60
...tree
http://git.netsurf-browser.org/libcss.git/tree/54ddec960162bb055b7dc50b1314763fbf763b60
The branch, master has been updated
via 54ddec960162bb055b7dc50b1314763fbf763b60 (commit)
via 682a216c41d55a0c8d76297f2411277b6c699e39 (commit)
from 1fb312312cdd01b3cf59950eacc7762f01c41a50 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=54ddec960162bb055b7dc50b1314763fbf763b60
commit 54ddec960162bb055b7dc50b1314763fbf763b60
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
tests: Add test for dodgy media block
To ensure we don't regress and fail on media blocks which
end with selectors with no ruleset, add a test to that effect.
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/test/data/parse2/INDEX b/test/data/parse2/INDEX
index e020747..331cf5c 100644
--- a/test/data/parse2/INDEX
+++ b/test/data/parse2/INDEX
@@ -22,3 +22,4 @@ padding.dat Padding property tests
multicol.dat Multi-column layout property tests
flexbox.dat Flexbox properties and shorthands tests
units.dat Length unit tests
+dodgy-media-block.dat Media block with incomplete ruleset
diff --git a/test/data/parse2/dodgy-media-block.dat
b/test/data/parse2/dodgy-media-block.dat
new file mode 100644
index 0000000..61179c3
--- /dev/null
+++ b/test/data/parse2/dodgy-media-block.dat
@@ -0,0 +1,9 @@
+#data
+@media only screen { dodgy } .outer { top: 0px }
+#errors
+#expected
+| @media
+| dodgy
+| .outer
+| top: 0px
+#reset
commitdiff
http://git.netsurf-browser.org/libcss.git/commit/?id=682a216c41d55a0c8d76297f2411277b6c699e39
commit 682a216c41d55a0c8d76297f2411277b6c699e39
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Add end-block-content parse event
In order to cope with a situation where a block ends with a
selector which has no ruleset, add an end-block-content event
and in handling it, pop any intermediate states off the language
stack so that we're in block mode by the time the event is completed.
This fixes an assert situation caused by a ruleset such as:
@media screen { dodgy } .outer { top: 10px; }
Which has been encountered in the wild (likely a typo).
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/src/parse/language.c b/src/parse/language.c
index 7fbfba7..c2d02d7 100644
--- a/src/parse/language.c
+++ b/src/parse/language.c
@@ -50,6 +50,8 @@ static css_error handleEndBlock(css_language *c,
const parserutils_vector *vector);
static css_error handleBlockContent(css_language *c,
const parserutils_vector *vector);
+static css_error handleEndBlockContent(css_language *c,
+ const parserutils_vector *vector);
static css_error handleDeclaration(css_language *c,
const parserutils_vector *vector);
@@ -219,6 +221,8 @@ css_error language_handle_event(css_parser_event type,
return handleEndBlock(language, tokens);
case CSS_PARSER_BLOCK_CONTENT:
return handleBlockContent(language, tokens);
+ case CSS_PARSER_END_BLOCK_CONTENT:
+ return handleEndBlockContent(language, tokens);
case CSS_PARSER_DECLARATION:
return handleDeclaration(language, tokens);
}
@@ -748,6 +752,40 @@ css_error handleBlockContent(css_language *c, const
parserutils_vector *vector)
return CSS_OK;
}
+css_error handleEndBlockContent(css_language *c, const parserutils_vector
*vector)
+{
+ context_entry *entry;
+ parserutils_error perror;
+ css_error ret;
+
+ /* First we call handleBlockContent() to deal with any intermediate
+ * tokens we have left
+ */
+ ret = handleBlockContent(c, vector);
+ if (ret != CSS_OK) {
+ return ret;
+ }
+
+ /* Our goal here is to ensure that the language parse stack is in the
+ * right state. We've encountered the end of a BlockContent such as
+ * @media ... { ... }
+ * and we need to ensure that the language stack reflects the end of
+ * that block, not any unfinished business within it such as
+ * @media ... { d }
+ */
+
+ entry = parserutils_stack_get_current(c->context);
+ while (entry != NULL && entry->type != CSS_PARSER_START_BLOCK) {
+ perror = parserutils_stack_pop(c->context, NULL);
+ if (perror != PARSERUTILS_OK) {
+ return css_error_from_parserutils_error(perror);
+ }
+ entry = parserutils_stack_get_current(c->context);
+ }
+
+ return CSS_OK;
+}
+
css_error handleDeclaration(css_language *c, const parserutils_vector *vector)
{
css_error error;
diff --git a/src/parse/parse.c b/src/parse/parse.c
index cbd8b56..d7cb357 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -1388,7 +1388,7 @@ css_error parseBlockContent(css_parser *parser)
#endif
if (parser->event != NULL) {
parser->event(
-
CSS_PARSER_BLOCK_CONTENT,
+
CSS_PARSER_END_BLOCK_CONTENT,
parser->tokens,
parser->event_pw);
}
diff --git a/src/parse/parse.h b/src/parse/parse.h
index e65f055..1e040de 100644
--- a/src/parse/parse.h
+++ b/src/parse/parse.h
@@ -31,6 +31,7 @@ typedef enum css_parser_event {
CSS_PARSER_START_BLOCK,
CSS_PARSER_END_BLOCK,
CSS_PARSER_BLOCK_CONTENT,
+ CSS_PARSER_END_BLOCK_CONTENT,
CSS_PARSER_DECLARATION
} css_parser_event;
-----------------------------------------------------------------------
Summary of changes:
src/parse/language.c | 38 ++++++++++++++++++++++++++++++++
src/parse/parse.c | 2 +-
src/parse/parse.h | 1 +
test/data/parse2/INDEX | 1 +
test/data/parse2/dodgy-media-block.dat | 9 ++++++++
5 files changed, 50 insertions(+), 1 deletion(-)
create mode 100644 test/data/parse2/dodgy-media-block.dat
diff --git a/src/parse/language.c b/src/parse/language.c
index 7fbfba7..c2d02d7 100644
--- a/src/parse/language.c
+++ b/src/parse/language.c
@@ -50,6 +50,8 @@ static css_error handleEndBlock(css_language *c,
const parserutils_vector *vector);
static css_error handleBlockContent(css_language *c,
const parserutils_vector *vector);
+static css_error handleEndBlockContent(css_language *c,
+ const parserutils_vector *vector);
static css_error handleDeclaration(css_language *c,
const parserutils_vector *vector);
@@ -219,6 +221,8 @@ css_error language_handle_event(css_parser_event type,
return handleEndBlock(language, tokens);
case CSS_PARSER_BLOCK_CONTENT:
return handleBlockContent(language, tokens);
+ case CSS_PARSER_END_BLOCK_CONTENT:
+ return handleEndBlockContent(language, tokens);
case CSS_PARSER_DECLARATION:
return handleDeclaration(language, tokens);
}
@@ -748,6 +752,40 @@ css_error handleBlockContent(css_language *c, const
parserutils_vector *vector)
return CSS_OK;
}
+css_error handleEndBlockContent(css_language *c, const parserutils_vector
*vector)
+{
+ context_entry *entry;
+ parserutils_error perror;
+ css_error ret;
+
+ /* First we call handleBlockContent() to deal with any intermediate
+ * tokens we have left
+ */
+ ret = handleBlockContent(c, vector);
+ if (ret != CSS_OK) {
+ return ret;
+ }
+
+ /* Our goal here is to ensure that the language parse stack is in the
+ * right state. We've encountered the end of a BlockContent such as
+ * @media ... { ... }
+ * and we need to ensure that the language stack reflects the end of
+ * that block, not any unfinished business within it such as
+ * @media ... { d }
+ */
+
+ entry = parserutils_stack_get_current(c->context);
+ while (entry != NULL && entry->type != CSS_PARSER_START_BLOCK) {
+ perror = parserutils_stack_pop(c->context, NULL);
+ if (perror != PARSERUTILS_OK) {
+ return css_error_from_parserutils_error(perror);
+ }
+ entry = parserutils_stack_get_current(c->context);
+ }
+
+ return CSS_OK;
+}
+
css_error handleDeclaration(css_language *c, const parserutils_vector *vector)
{
css_error error;
diff --git a/src/parse/parse.c b/src/parse/parse.c
index cbd8b56..d7cb357 100644
--- a/src/parse/parse.c
+++ b/src/parse/parse.c
@@ -1388,7 +1388,7 @@ css_error parseBlockContent(css_parser *parser)
#endif
if (parser->event != NULL) {
parser->event(
-
CSS_PARSER_BLOCK_CONTENT,
+
CSS_PARSER_END_BLOCK_CONTENT,
parser->tokens,
parser->event_pw);
}
diff --git a/src/parse/parse.h b/src/parse/parse.h
index e65f055..1e040de 100644
--- a/src/parse/parse.h
+++ b/src/parse/parse.h
@@ -31,6 +31,7 @@ typedef enum css_parser_event {
CSS_PARSER_START_BLOCK,
CSS_PARSER_END_BLOCK,
CSS_PARSER_BLOCK_CONTENT,
+ CSS_PARSER_END_BLOCK_CONTENT,
CSS_PARSER_DECLARATION
} css_parser_event;
diff --git a/test/data/parse2/INDEX b/test/data/parse2/INDEX
index e020747..331cf5c 100644
--- a/test/data/parse2/INDEX
+++ b/test/data/parse2/INDEX
@@ -22,3 +22,4 @@ padding.dat Padding property tests
multicol.dat Multi-column layout property tests
flexbox.dat Flexbox properties and shorthands tests
units.dat Length unit tests
+dodgy-media-block.dat Media block with incomplete ruleset
diff --git a/test/data/parse2/dodgy-media-block.dat
b/test/data/parse2/dodgy-media-block.dat
new file mode 100644
index 0000000..61179c3
--- /dev/null
+++ b/test/data/parse2/dodgy-media-block.dat
@@ -0,0 +1,9 @@
+#data
+@media only screen { dodgy } .outer { top: 0px }
+#errors
+#expected
+| @media
+| dodgy
+| .outer
+| top: 0px
+#reset
--
Cascading Style Sheets library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org