]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Further fixes for tag state machine
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Jul 2021 13:12:58 +0000 (14:12 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 13 Jul 2021 13:13:24 +0000 (14:13 +0100)
src/libserver/html/html.cxx
src/libserver/html/html_tests.cxx

index bd323b43f054bd6627de084bd1a07cdeaa392d26..5d2479ab4d7de32d56b8260e7138d292d9d802c6 100644 (file)
@@ -388,9 +388,8 @@ html_parse_tag_content(rspamd_mempool_t *pool,
                                /* Should never be in attribute names but ignored */
                                tag->flags |= FL_BROKEN;
                        }
-                       else {
-                               store_value_character(true);
-                       }
+
+                       store_value_character(true);
                }
 
                break;
@@ -421,11 +420,13 @@ html_parse_tag_content(rspamd_mempool_t *pool,
                                hc->flags |= RSPAMD_HTML_FLAG_BAD_ELEMENTS;
                                tag->flags |= FL_BROKEN;
                                store_component_value();
+                               store_value_character(true);
                                state = spaces_after_param;
                        }
                        else {
                                /* Empty attribute */
                                store_component_value();
+                               store_value_character(true);
                                state = spaces_after_param;
                        }
                }
@@ -539,6 +540,8 @@ html_parse_tag_content(rspamd_mempool_t *pool,
                        else if (*in == '=') {
                                /* Attributes cannot start with '=' */
                                tag->flags |= FL_BROKEN;
+                               store_value_character(true);
+                               state = parse_attr_name;
                        }
                        else {
                                store_value_character(true);
index 07618b2737dafefecccfe86e6583d336021f997e..a0c60b2998367671144837bdc752c08b182dae42 100644 (file)
@@ -221,7 +221,8 @@ TEST_CASE("html urls extraction")
 {
        using namespace std::string_literals;
        const std::vector<std::pair<std::string, std::vector<std::string>>> cases{
-                       {"<a href=\"https://example.com\">test</a>", {"https://example.com"}}
+                       {"<a href=\"https://example.com\">test</a>", {"https://example.com"}},
+                       {"<a <poo href=\"http://example.com\">hello</a>", {"http://example.com"}},
        };
 
        rspamd_url_init(NULL);
@@ -244,6 +245,7 @@ TEST_CASE("html urls extraction")
                        g_byte_array_free(tmp, TRUE);
                        g_ptr_array_free(purls, TRUE);
                }
+               ++i;
        }
 
        rspamd_mempool_delete(pool);