diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-23 20:41:02 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-07-23 20:41:02 +0100 |
commit | eef2f3cac7c975af050efaf4cf1acafcb9b501e3 (patch) | |
tree | 1faf0c72dc3ce69ce56d21dcf1b6b5ffd757aa0f /src/libserver/html | |
parent | 80e8a76a31943ee23cec774888b575a69a1360f1 (diff) | |
download | rspamd-eef2f3cac7c975af050efaf4cf1acafcb9b501e3.tar.gz rspamd-eef2f3cac7c975af050efaf4cf1acafcb9b501e3.zip |
[Feature] Reorganise struct rspamd_url to be 64 bytes size
Diffstat (limited to 'src/libserver/html')
-rw-r--r-- | src/libserver/html/html_url.cxx | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/libserver/html/html_url.cxx b/src/libserver/html/html_url.cxx index 0068ea30f..ae2514ba1 100644 --- a/src/libserver/html/html_url.cxx +++ b/src/libserver/html/html_url.cxx @@ -183,8 +183,12 @@ html_url_is_phished(rspamd_mempool_t *pool, if (!rspamd_url_is_subdomain(disp_tok, href_tok)) { href_url->flags |= RSPAMD_URL_FLAG_PHISHED; - href_url->linked_url = text_url; text_url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED; + + if (href_url->ext == nullptr) { + href_url->ext = rspamd_mempool_alloc0_type(pool, rspamd_url_ext); + } + href_url->ext->linked_url = text_url; } } } @@ -241,18 +245,21 @@ html_check_displayed_url(rspamd_mempool_t *pool, return; } - url->visible_part = rspamd_mempool_alloc_buffer(pool, visible_part.size() + 1); - rspamd_strlcpy(url->visible_part, + if (url->ext == nullptr) { + url->ext = rspamd_mempool_alloc0_type(pool, rspamd_url_ext); + } + url->ext->visible_part = rspamd_mempool_alloc_buffer(pool, visible_part.size() + 1); + rspamd_strlcpy(url->ext->visible_part, visible_part.data(), visible_part.size() + 1); dlen = visible_part.size(); /* Strip unicode spaces from the start and the end */ - url->visible_part = const_cast<char *>( - rspamd_string_unicode_trim_inplace(url->visible_part, + url->ext->visible_part = const_cast<char *>( + rspamd_string_unicode_trim_inplace(url->ext->visible_part, &dlen)); auto maybe_url = html_url_is_phished(pool, url, - {url->visible_part, dlen}); + {url->ext->visible_part, dlen}); if (maybe_url) { url->flags |= saved_flags; @@ -300,7 +307,7 @@ html_check_displayed_url(rspamd_mempool_t *pool, } } - rspamd_normalise_unicode_inplace(url->visible_part, &dlen); + rspamd_normalise_unicode_inplace(url->ext->visible_part, &dlen); } auto |