diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-01-29 14:40:40 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-01-29 14:40:40 +0000 |
commit | 826a8097a2b27f7013faa1b549068e3e09dbc4fd (patch) | |
tree | 71afafe44bf799d4a49df093d69790226f5fd003 | |
parent | f3ce044e0892718c69017d7d16c1ebeceffedcf1 (diff) | |
download | rspamd-826a8097a2b27f7013faa1b549068e3e09dbc4fd.tar.gz rspamd-826a8097a2b27f7013faa1b549068e3e09dbc4fd.zip |
[Project] Css: Fix minus parsing
-rw-r--r-- | src/libserver/css/css_tokeniser.cxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx index 71304a4d1..d43920817 100644 --- a/src/libserver/css/css_tokeniser.cxx +++ b/src/libserver/css/css_tokeniser.cxx @@ -217,6 +217,7 @@ auto css_tokeniser::consume_ident() -> struct css_parser_token { auto i = offset; auto need_escape = false; + auto allow_middle_minus = false; auto maybe_escape_sv = [&](auto cur_pos, auto tok_type) -> auto { if (need_escape) { @@ -239,6 +240,7 @@ auto css_tokeniser::consume_ident() -> struct css_parser_token if (i < input.size() && input[i] == '-') { i ++; + allow_middle_minus = true; } } @@ -307,10 +309,17 @@ auto css_tokeniser::consume_ident() -> struct css_parser_token } } } + else if (c == '-' && allow_middle_minus) { + i++; + continue; + } else { break; /* Not an ident token */ } } /* !plain ident */ + else { + allow_middle_minus = true; + } i ++; } @@ -392,6 +401,8 @@ auto css_tokeniser::consume_number() -> struct css_parser_token auto sv = std::get<std::string_view>(dim_token.value); msg_debug_css("cannot apply dimension from the token %*s; number value = %.1f", (int)sv.size(), sv.begin(), num); + /* Unconsume ident */ + offset = i; } } else { |