commit d12d563: [Minor] Lowercase id and class components

Vsevolod Stakhov vsevolod at highsecure.ru
Tue Jul 20 13:42:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-07-20 14:39:20 +0100
URL: https://github.com/rspamd/rspamd/commit/d12d563873826906bdd2d16f45818d3811ff73d2 (HEAD -> master)

[Minor] Lowercase id and class components

---
 src/libserver/html/html.cxx | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index 0925a7695..d60210ba6 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -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 {


More information about the Commits mailing list