]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] One more fix for checking displayed urls
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 6 Aug 2021 12:24:54 +0000 (13:24 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 6 Aug 2021 12:24:54 +0000 (13:24 +0100)
src/libserver/html/html_url.cxx

index 22f201f8cdc5f3c99e7ed5141fdb7745142411c1..0c00d804858448bbc86bcb99d2c18678d3d6b562 100644 (file)
@@ -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;
+                                               }
                                        }
                                }
                        }