summaryrefslogtreecommitdiffstats
path: root/src/libserver/css/css_tokeniser.cxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-03 21:41:55 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-03-03 21:41:55 +0000
commit7954b67e2d51a94e47e89767c2382da490973f9f (patch)
tree3e13f2260e24f0b57e5655e40128c0db572d3b42 /src/libserver/css/css_tokeniser.cxx
parent25a8f48d565a0450aed3417c88dbeeecdad11532 (diff)
downloadrspamd-7954b67e2d51a94e47e89767c2382da490973f9f.tar.gz
rspamd-7954b67e2d51a94e47e89767c2382da490973f9f.zip
[Porject] Css: Rework functions parsing
Diffstat (limited to 'src/libserver/css/css_tokeniser.cxx')
-rw-r--r--src/libserver/css/css_tokeniser.cxx51
1 files changed, 30 insertions, 21 deletions
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++;