commit b7fed97: [Minor] Allow urls with no tld when no tld file is loaded

Vsevolod Stakhov vsevolod at rspamd.com
Sat Nov 19 20:28:16 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-11-13 19:44:24 +0000
URL: https://github.com/rspamd/rspamd/commit/b7fed9744e3008f6a1387c6d56325c31908e1768

[Minor] Allow urls with no tld when no tld file is loaded

---
 src/libserver/url.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/libserver/url.c b/src/libserver/url.c
index 932cd9e85..4984b0d2d 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -284,6 +284,7 @@ struct url_match_scanner {
 	GArray *matchers_strict;
 	struct rspamd_multipattern *search_trie_full;
 	struct rspamd_multipattern *search_trie_strict;
+	bool has_tld_file;
 };
 
 struct url_match_scanner *url_scanner = NULL;
@@ -602,10 +603,12 @@ rspamd_url_init (const gchar *tld_file)
 				sizeof (struct url_matcher), 13000);
 		url_scanner->search_trie_full = rspamd_multipattern_create_sized (13000,
 				RSPAMD_MULTIPATTERN_ICASE|RSPAMD_MULTIPATTERN_UTF8);
+		url_scanner->has_tld_file = true;
 	}
 	else {
 		url_scanner->matchers_full = NULL;
 		url_scanner->search_trie_full = NULL;
+		url_scanner->has_tld_file = false;
 	}
 
 	rspamd_url_add_static_matchers (url_scanner);
@@ -2490,7 +2493,7 @@ rspamd_url_parse (struct rspamd_url *uri,
 
 		if (uri->tldlen == 0) {
 			if (uri->protocol != PROTOCOL_MAILTO) {
-				if (!(parse_flags & RSPAMD_URL_PARSE_HREF)) {
+				if (url_scanner->has_tld_file && !(parse_flags & RSPAMD_URL_PARSE_HREF)) {
 					/* Ignore URL's without TLD if it is not a numeric URL */
 					if (!rspamd_url_is_ip(uri, pool)) {
 						return URI_ERRNO_TLD_MISSING;


More information about the Commits mailing list