summaryrefslogtreecommitdiff
path: root/source/html/css-parse.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2014-11-27 15:56:06 +0100
committerTor Andersson <tor.andersson@artifex.com>2014-12-03 12:25:52 +0100
commit1cb7f8f9ae768b680477212c678a3111fca71ef7 (patch)
tree25767cb0b1ed13c7d7c726e9928aa73fafc54839 /source/html/css-parse.c
parent71fdae79c38fee74c060cb41eee9b6e1257e1fb6 (diff)
downloadmupdf-1cb7f8f9ae768b680477212c678a3111fca71ef7.tar.xz
html: Fix parsing of @-rules in CSS.
Diffstat (limited to 'source/html/css-parse.c')
-rw-r--r--source/html/css-parse.c48
1 files changed, 18 insertions, 30 deletions
diff --git a/source/html/css-parse.c b/source/html/css-parse.c
index db17e431..18f33e16 100644
--- a/source/html/css-parse.c
+++ b/source/html/css-parse.c
@@ -789,42 +789,30 @@ static fz_css_rule *parse_rule(struct lexbuf *buf)
return fz_new_css_rule(buf->ctx, s, p);
}
-static void parse_media_list(struct lexbuf *buf)
-{
- fz_css_rule *r;
-
- while (buf->lookahead != '}' && buf->lookahead != EOF)
- {
- r = parse_rule(buf);
- fz_free_css(buf->ctx, r);
- }
-}
-
static void parse_at_rule(struct lexbuf *buf)
{
- fz_css_property *p;
- fz_css_value *v;
-
expect(buf, CSS_KEYWORD);
- if (accept(buf, '{')) /* @page */
- {
- p = parse_declaration_list(buf);
- fz_free_css_property(buf->ctx, p);
- expect(buf, '}');
- }
- else
+
+ /* skip until '{' or ';' */
+ while (buf->lookahead != EOF)
{
- v = parse_value_list(buf);
- fz_free_css_value(buf->ctx, v);
- if (accept(buf, '{')) /* @media */
+ if (accept(buf, ';'))
+ return;
+ if (accept(buf, '{'))
{
- parse_media_list(buf);
- expect(buf, '}');
- }
- else /* @import */
- {
- expect(buf, ';');
+ int depth = 1;
+ while (buf->lookahead != EOF && depth > 0)
+ {
+ if (accept(buf, '{'))
+ ++depth;
+ else if (accept(buf, '}'))
+ --depth;
+ else
+ next(buf);
+ }
+ return;
}
+ next(buf);
}
}