]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Lowercase id and class components
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Jul 2021 13:39:20 +0000 (14:39 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 20 Jul 2021 13:39:20 +0000 (14:39 +0100)
src/libserver/html/html.cxx

index 0925a7695277ce3e8d08611d7b48a4386d14fe06..d60210ba6e15857b95c5de742d3fc01618467df3 100644 (file)
@@ -269,7 +269,16 @@ html_parse_tag_content(rspamd_mempool_t *pool,
                        else {
                                /* We need to copy buf to a persistent storage */
                                auto *s = rspamd_mempool_alloc_buffer(pool, parser_env.buf.size());
-                               memcpy(s, parser_env.buf.data(), parser_env.buf.size());
+
+                               if (parser_env.cur_component.value() == html_component_type::RSPAMD_HTML_COMPONENT_ID ||
+                                               parser_env.cur_component.value() == html_component_type::RSPAMD_HTML_COMPONENT_CLASS) {
+                                       /* Lowercase */
+                                       rspamd_str_copy_lc(parser_env.buf.data(), s, parser_env.buf.size());
+                               }
+                               else {
+                                       memcpy(s, parser_env.buf.data(), parser_env.buf.size());
+                               }
+
                                auto sz = rspamd_html_decode_entitles_inplace(s, parser_env.buf.size());
                                tag->components.emplace_back(parser_env.cur_component.value(),
                                                std::string_view{s, sz});
@@ -1104,7 +1113,8 @@ html_append_tag_content(rspamd_mempool_t *pool,
                                is_visible = false;
                        }
                        else {
-                               if (tag->block->has_display() && tag->block->display == css::css_display_value::DISPLAY_HIDDEN) {
+                               if (tag->block->has_display() &&
+                                       tag->block->display == css::css_display_value::DISPLAY_HIDDEN) {
                                        is_visible = false;
                                }
                                else {