commit 2e6f1eb: [Minor] Store multiple base tags (but use only first one as usually)

Vsevolod Stakhov vsevolod at highsecure.ru
Wed Aug 25 16:42:04 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-08-25 17:37:21 +0100
URL: https://github.com/rspamd/rspamd/commit/2e6f1ebd706f3e9023babcc19b69f838b5eff2a8 (HEAD -> master)

[Minor] Store multiple base tags (but use only first one as usually)

---
 src/libserver/html/html.cxx | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/libserver/html/html.cxx b/src/libserver/html/html.cxx
index ef7fb35ba..e4cc137b4 100644
--- a/src/libserver/html/html.cxx
+++ b/src/libserver/html/html.cxx
@@ -1413,19 +1413,23 @@ html_process_input(rspamd_mempool_t *pool,
 			/*
 			 * Base is allowed only within head tag but HTML is retarded
 			 */
-			if (hc->base_url == NULL) {
-				auto maybe_url = html_process_url_tag(pool, cur_tag, hc);
+			auto maybe_url = html_process_url_tag(pool, cur_tag, hc);
+
+			if (maybe_url) {
+				msg_debug_html ("got valid base tag");
+				cur_tag->extra = maybe_url.value();
+				cur_tag->flags |= FL_HREF;
 
-				if (maybe_url) {
-					msg_debug_html ("got valid base tag");
+				if (hc->base_url == nullptr) {
 					hc->base_url = maybe_url.value();
-					cur_tag->extra = maybe_url.value();
-					cur_tag->flags |= FL_HREF;
 				}
 				else {
-					msg_debug_html ("got invalid base tag!");
+					msg_debug_html ("ignore redundant base tag");
 				}
 			}
+			else {
+				msg_debug_html ("got invalid base tag!");
+			}
 		}
 
 		if (cur_tag->id == Tag_IMG) {


More information about the Commits mailing list