]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Css: Fix hash tokens parsing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 6 May 2021 10:21:15 +0000 (11:21 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 6 May 2021 10:21:15 +0000 (11:21 +0100)
src/libserver/css/css_parser.cxx
src/libserver/css/css_tokeniser.cxx
src/libserver/css/css_tokeniser.hxx

index 49b42021c83dc728f7d509d44a6fbe5eeb3e42a8..d7b1c8ca8aa678617c41dc1a9136ec277050787f 100644 (file)
@@ -833,6 +833,8 @@ TEST_SUITE("css parser") {
                        "em { color: rgba(100%,0%,0%,1) } /* the same, with explicit opacity of 1 */\n",
                        "p { color: rgba(0,0,255,0.5) }        /* semi-transparent solid blue */\n",
                        "p { color: rgba(100%, 50%, 0%, 0.1) } /* very transparent solid orange */",
+                       ".chat-icon[_ng-cnj-c0]::before{content:url(group-2.63e87cd21fbf8c966dd.svg);width:60px;height:60px;display:block}",
+                       "tt{color:#1e3482}",
                };
 
                rspamd_mempool_t *pool = rspamd_mempool_new(rspamd_mempool_suggest_size(),
index 5b0a0c086a45fcbcfbdf1221f6d176cbb5073023..0374193bf766794fa65df8184c9b97df67a4f817 100644 (file)
@@ -177,7 +177,7 @@ css_parser_token::adjust_dim(const css_parser_token &dim_token) -> bool
 /*
  * Consume functions: return a token and advance lexer offset
  */
-auto css_tokeniser::consume_ident() -> struct css_parser_token
+auto css_tokeniser::consume_ident(bool allow_number) -> struct css_parser_token
 {
        auto i = offset;
        auto need_escape = false;
@@ -211,7 +211,7 @@ auto css_tokeniser::consume_ident() -> struct css_parser_token
        while (i < input.size()) {
                auto c = input[i];
 
-               auto is_plain_c = allow_middle_minus ? is_plain_ident(c) :
+               auto is_plain_c = (allow_number || allow_middle_minus) ? is_plain_ident(c) :
                                                  is_plain_ident_start(c);
                if (!is_plain_c) {
                        if (c == '\\' && i + 1 < input.size ()) {
@@ -533,8 +533,8 @@ auto css_tokeniser::next_token(void) -> struct css_parser_token
                case '\r':
                case '\v': {
                        /* Consume as much space as we can */
-                       while (i < input.size() && g_ascii_isspace(c)) {
-                               c = input[i++];
+                       while (i < input.size() && g_ascii_isspace(input[i])) {
+                               i++;
                        }
 
                        auto ret = make_token<css_parser_token::token_type::whitespace_token>(
@@ -675,7 +675,8 @@ auto css_tokeniser::next_token(void) -> struct css_parser_token
                                if ((is_plain_ident(next_c) || next_c == '-') &&
                                                (is_plain_ident(next_next_c) || next_next_c == '-')) {
                                        offset = i + 1;
-                                       auto ident_token = consume_ident();
+                                       /* We consume indent, but we allow numbers there */
+                                       auto ident_token = consume_ident(true);
 
                                        if (ident_token.type == css_parser_token::token_type::ident_token) {
                                                /* Update type */
index 4a484ecd6e839e62f2f889c1a7ae926c03a863c4..a45e56f3f4046cdb1d0f29503f2bb80b8d478f24 100644 (file)
@@ -194,7 +194,7 @@ private:
        mutable std::list<css_parser_token> backlog;
 
        auto consume_number() -> struct css_parser_token;
-       auto consume_ident() -> struct css_parser_token;
+       auto consume_ident(bool allow_number = false) -> struct css_parser_token;
 };
 
 }