From: Vsevolod Stakhov Date: Fri, 6 Aug 2021 12:24:54 +0000 (+0100) Subject: [Minor] One more fix for checking displayed urls X-Git-Tag: 3.0~43 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e947bbb495026a273ffede493fff682cc4ec207c;p=rspamd.git [Minor] One more fix for checking displayed urls --- diff --git a/src/libserver/html/html_url.cxx b/src/libserver/html/html_url.cxx index 22f201f8c..0c00d8048 100644 --- a/src/libserver/html/html_url.cxx +++ b/src/libserver/html/html_url.cxx @@ -159,24 +159,29 @@ html_url_is_phished(rspamd_mempool_t *pool, auto rc = rspamd_url_parse(text_url, url_str, strlen(url_str), pool, RSPAMD_URL_PARSE_TEXT); - if (rc == URI_ERRNO_OK && is_transfer_proto(text_url) == is_transfer_proto(href_url)) { - disp_tok = convert_idna_hostname_maybe(pool, text_url, false); - href_tok = convert_idna_hostname_maybe(pool, href_url, false); + if (rc == URI_ERRNO_OK) { + text_url->flags |= RSPAMD_URL_FLAG_HTML_DISPLAYED; - if (!sv_equals(disp_tok, href_tok) && - text_url->tldlen > 0 && href_url->tldlen > 0) { + /* Check for phishing */ + if (is_transfer_proto(text_url) == is_transfer_proto(href_url)) { + disp_tok = convert_idna_hostname_maybe(pool, text_url, false); + href_tok = convert_idna_hostname_maybe(pool, href_url, false); - /* Apply the same logic for TLD */ - disp_tok = convert_idna_hostname_maybe(pool, text_url, true); - href_tok = convert_idna_hostname_maybe(pool, href_url, true); + if (!sv_equals(disp_tok, href_tok) && + text_url->tldlen > 0 && href_url->tldlen > 0) { - if (!sv_equals(disp_tok, href_tok)) { - /* Check if one url is a subdomain for another */ + /* Apply the same logic for TLD */ + disp_tok = convert_idna_hostname_maybe(pool, text_url, true); + href_tok = convert_idna_hostname_maybe(pool, href_url, true); - 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 (!sv_equals(disp_tok, href_tok)) { + /* Check if one url is a subdomain for another */ + + 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; + } } } }