commit 826a809: [Project] Css: Fix minus parsing
Vsevolod Stakhov
vsevolod at highsecure.ru
Fri Jan 29 14:42:10 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-01-29 14:40:40 +0000
URL: https://github.com/rspamd/rspamd/commit/826a8097a2b27f7013faa1b549068e3e09dbc4fd (HEAD -> master)
[Project] Css: Fix minus parsing
---
src/libserver/css/css_tokeniser.cxx | 11 +++++++++++
1 file changed, 11 insertions(+)
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 {
More information about the Commits
mailing list