]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix styles processing
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 23 Jun 2021 12:14:26 +0000 (13:14 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 23 Jun 2021 12:14:26 +0000 (13:14 +0100)
src/libserver/css/css_selector.cxx
src/libserver/html/html.cxx

index 28b64a9fde383e515e7b60c149ddc154ba3979f7..75baec8f230530186371bf39df055be3fdebbeba 100644 (file)
@@ -152,6 +152,9 @@ auto process_selector_tokens(rspamd_mempool_t *pool,
                                msg_debug_css("attached selector: %s", cur_selector->debug_str().c_str());
                                ret.push_back(std::move(cur_selector));
                        }
+                       else {
+                               msg_debug_css("not attached selector, state: %d", static_cast<int>(state));
+                       }
                        can_continue = false;
                }
 
index 6a7a6facf031bf2e2bf64faf7dc2532ca774492c..9261258bc834813b93e80728a350640d042e6146 100644 (file)
@@ -1473,14 +1473,17 @@ html_process_input(rspamd_mempool_t *pool,
                case content_style: {
 
                        /*
-                        * We just search for the first </s substring and then pass
+                        * We just search for the first </style> substring and then pass
                         * the content to the parser (if needed)
+                        *
+                        * TODO: Handle other stuff, we actually need an FSM here to find
+                        * the ending tag...
                         */
-                       auto end_style = rspamd_substring_search (p, end - p,
-                                       "</", 2);
-                       if (end_style == -1 || g_ascii_tolower (p[end_style + 2]) != 's') {
+                       auto end_style = rspamd_substring_search_caseless(p, end - p,
+                                       "</style>", 8);
+                       if (end_style == -1) {
                                /* Invalid style */
-                               state = tag_content;
+                               state = html_text_content;
                        }
                        else {
 
@@ -1540,16 +1543,11 @@ html_process_input(rspamd_mempool_t *pool,
                        content_parser_env.reset();
 
                        if (cur_tag != nullptr) {
-                               state = html_text_content;
 
                                cur_tag->content_offset = p - start + 1;
 
-                               if (!html_process_tag(pool, hc, cur_tag, tags_stack,
-                                               c - start, p - start)) {
-                                       if (cur_tag->id == Tag_STYLE) {
-                                               state = content_style;
-                                       }
-                               }
+                               html_process_tag(pool, hc, cur_tag, tags_stack,
+                                               c - start, p - start);
 
                                if (cur_tag->id != -1 && cur_tag->id < N_TAGS) {
                                        if (cur_tag->flags & CM_UNIQUE) {
@@ -1623,7 +1621,13 @@ html_process_input(rspamd_mempool_t *pool,
                                }
                        }
 
-                       state = html_text_content;
+                       if (cur_tag->id == Tag_STYLE && !(cur_tag->flags & FL_CLOSING)) {
+                               state = content_style;
+                       }
+                       else {
+                               state = html_text_content;
+                       }
+
                        p++;
                        c = p;
                        cur_tag = NULL;