commit acf1756: [Project] Css: Finish generic lexer cases
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Jan 28 16:14:09 UTC 2021
Author: Vsevolod Stakhov
Date: 2021-01-28 15:47:23 +0000
URL: https://github.com/rspamd/rspamd/commit/acf1756dfae5a93e0348eae74809d343e696f44b
[Project] Css: Finish generic lexer cases
---
src/libserver/css/css_tokeniser.cxx | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/libserver/css/css_tokeniser.cxx b/src/libserver/css/css_tokeniser.cxx
index 534ae3426..3d1749913 100644
--- a/src/libserver/css/css_tokeniser.cxx
+++ b/src/libserver/css/css_tokeniser.cxx
@@ -381,6 +381,8 @@ auto css_tokeniser::consume_number() -> struct css_parser_token
if (input[i] == '%') {
ret.flags |= css_parser_token::number_percent;
i ++;
+
+ offset = i;
}
else if (is_plain_ident(input[i])) {
auto dim_token = consume_ident();
@@ -392,8 +394,16 @@ auto css_tokeniser::consume_number() -> struct css_parser_token
(int)sv.size(), sv.begin(), num);
}
}
+ else {
+ /* We have no option but to uncosume ident token in this case */
+ msg_debug_css("got invalid ident like token after number, unconsume it");
+ offset = i;
+ }
}
}
+ else {
+ offset = i;
+ }
return ret;
}
@@ -677,6 +687,17 @@ auto css_tokeniser::next_token(void) -> struct css_parser_token
break;
default:
/* Generic parsing code */
+
+ if (g_ascii_isdigit(c)) {
+ return consume_number();
+ }
+ else if (is_plain_ident(c)) {
+ return consume_ident();
+ }
+ else {
+ offset = i + 1;
+ return make_token<css_parser_token::token_type::delim_token>(c);
+ }
break;
}
More information about the Commits
mailing list