From 7954b67e2d51a94e47e89767c2382da490973f9f Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 3 Mar 2021 21:41:55 +0000 Subject: [Porject] Css: Rework functions parsing --- src/libserver/css/css_tokeniser.cxx | 51 ++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 21 deletions(-) (limited to 'src/libserver/css/css_tokeniser.cxx') diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx index f3a2767bd..1d6e89df7 100644 --- a/src/libserver/css/css_tokeniser.cxx +++ b/src/libserver/css/css_tokeniser.cxx @@ -246,34 +246,43 @@ auto css_tokeniser::consume_ident() -> struct css_parser_token auto j = i + 1; while (j < input.size() && g_ascii_isspace(input[j])) { - j ++; + j++; } - if (input[j] == '"' || input[j] == '\'') { - /* Function token */ - return maybe_escape_sv(j + 1, - css_parser_token::token_type::function_token); - } - else { - /* Consume URL token */ - while (j < input.size() && input[j] != ')') { - j ++; - } - - if (input[j] == ')') { - /* Valid url token */ - return maybe_escape_sv(j + 1, - css_parser_token::token_type::url_token); + if (input.size() > 3 && input.substr(0, 3) == "url") { + if (input[j] == '"' || input[j] == '\'') { + /* Function token */ + auto ret = maybe_escape_sv(i, + css_parser_token::token_type::function_token); + return ret; } else { - /* Incomplete url token */ - auto ret = maybe_escape_sv(j, - css_parser_token::token_type::url_token); + /* Consume URL token */ + while (j < input.size() && input[j] != ')') { + j++; + } - ret.flags |= css_parser_token::flag_bad_string; - return ret; + if (input[j] == ')') { + /* Valid url token */ + auto ret = maybe_escape_sv(j + 1, + css_parser_token::token_type::url_token); + return ret; + } + else { + /* Incomplete url token */ + auto ret = maybe_escape_sv(j, + css_parser_token::token_type::url_token); + + ret.flags |= css_parser_token::flag_bad_string; + return ret; + } } } + else { + auto ret = maybe_escape_sv(i, + css_parser_token::token_type::function_token); + return ret; + } } else if (c == '-' && allow_middle_minus) { i++; -- cgit v1.2.3