diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-04-14 10:55:35 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-04-14 11:10:11 +0200 |
commit | 1bc74dac2b251764d373c164e2b5235875f27901 (patch) | |
tree | 0e408679c8aadfda05e7cef32987496cb3a4c474 | |
parent | 36ee18b6ade036285cfe665a0dda3d53f06b2a32 (diff) | |
download | mupdf-1bc74dac2b251764d373c164e2b5235875f27901.tar.xz |
epub: Parse url() tokens.
Fix bug 695922.
-rw-r--r-- | source/html/css-parse.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/source/html/css-parse.c b/source/html/css-parse.c index 91958a98..ff364fc7 100644 --- a/source/html/css-parse.c +++ b/source/html/css-parse.c @@ -311,6 +311,38 @@ static int css_lex_string(struct lexbuf *buf, int q) return CSS_STRING; } +static void css_lex_uri(struct lexbuf *buf) +{ + while (buf->c && buf->c != ')' && !iswhite(buf->c)) + { + if (css_lex_accept(buf, '\\')) + { + if (css_lex_accept(buf, 'n')) + css_push_char(buf, '\n'); + else if (css_lex_accept(buf, 'r')) + css_push_char(buf, '\r'); + else if (css_lex_accept(buf, 'f')) + css_push_char(buf, '\f'); + else + { + css_push_char(buf, buf->c); + css_lex_next(buf); + } + } + else if (buf->c == '!' || buf->c == '#' || buf->c == '$' || buf->c == '%' || buf->c == '&' || + (buf->c >= '*' && buf->c <= '[') || + (buf->c >= ']' && buf->c <= '~') || + buf->c > 159) + { + css_push_char(buf, buf->c); + css_lex_next(buf); + } + else + fz_css_error(buf, "unexpected character in url"); + } + css_push_char(buf, 0); +} + static int css_lex(struct lexbuf *buf) { int t; @@ -436,7 +468,16 @@ colorerror: { if (css_lex_accept(buf, '(')) { - // string or url + while (iswhite(buf->c)) + css_lex_next(buf); + if (css_lex_accept(buf, '"')) + css_lex_string(buf, '"'); + else if (css_lex_accept(buf, '\'')) + css_lex_string(buf, '\''); + else + css_lex_uri(buf); + while (iswhite(buf->c)) + css_lex_next(buf); css_lex_expect(buf, ')'); return CSS_URI; } |