]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Set special flag for non A generated html urls
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Jan 2022 20:25:27 +0000 (20:25 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 11 Jan 2022 20:25:27 +0000 (20:25 +0000)
src/libserver/html/html.cxx
src/libserver/html/html_url.cxx

index 79120d1098569321bab678fba05151f033b7dc3c..4711a3caf53044a676b713148408a9cc795c033c 100644 (file)
@@ -677,10 +677,17 @@ html_process_url_tag(rspamd_mempool_t *pool,
                        }
                }
 
-               auto url = html_process_url(pool, href_value);
+               auto url = html_process_url(pool, href_value).value_or(nullptr);
 
-               if (url && std::holds_alternative<std::monostate>(tag->extra)) {
-                       tag->extra = url.value();
+               if (url) {
+                       if (tag->id != Tag_A) {
+                               /* Mark special tags special */
+                               url->flags |= RSPAMD_URL_FLAG_SPECIAL;
+                       }
+
+                       if (std::holds_alternative<std::monostate>(tag->extra)) {
+                               tag->extra = url;
+                       }
                }
 
                return url;
@@ -949,7 +956,10 @@ html_process_img_tag(rspamd_mempool_t *pool,
        }
 
        hc->images.push_back(img);
-       tag->extra = img;
+
+       if (std::holds_alternative<std::monostate>(tag->extra)) {
+               tag->extra = img;
+       }
 }
 
 static auto
index 93fef68d1322cbceeea39fbf93df41074d1635e5..34775ba135fc49da840cbd15e010530212e9e1f9 100644 (file)
@@ -276,9 +276,17 @@ html_check_displayed_url(rspamd_mempool_t *pool,
                         * HTML part, we assume that it is also
                         * hint only.
                         */
-                       if (turl->flags &
-                               RSPAMD_URL_FLAG_FROM_TEXT) {
-                               turl->flags |= displayed_url->flags;
+                       if (turl->flags & RSPAMD_URL_FLAG_FROM_TEXT) {
+
+                               /*
+                                * We have the same URL for href and displayed url, so we
+                                * know that this url cannot be both target and display (as
+                                * it breaks logic in many places), so we do not
+                                * propagate html flags
+                                */
+                               if (!(turl->flags & RSPAMD_URL_FLAG_DISPLAY_URL)) {
+                                       turl->flags |= displayed_url->flags;
+                               }
                                turl->flags &= ~RSPAMD_URL_FLAG_FROM_TEXT;
                        }