diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-10 13:32:02 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-08-10 13:32:02 +0100 |
commit | 0f36dc9a5582091fed54bb2f790b629d8737141e (patch) | |
tree | 2cb2d8253e9db7fff798994c6896e372f4082e63 /src | |
parent | d029c2a4004b91c87482e7c5b2e96b93179ddb56 (diff) | |
download | rspamd-0f36dc9a5582091fed54bb2f790b629d8737141e.tar.gz rspamd-0f36dc9a5582091fed54bb2f790b629d8737141e.zip |
[Minor] Treat last dot specially
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/url.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index ab32549c7..ca0b2072e 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -2474,9 +2474,10 @@ rspamd_url_parse(struct rspamd_url *uri, } } + char last_c = rspamd_url_host_unsafe(uri)[uri->hostlen - 1]; + if (all_chars_domain) { /* Also check the last character to be either a dot or alphanumeric character */ - char last_c = rspamd_url_host_unsafe(uri)[uri->hostlen - 1]; if (last_c != '.' && !g_ascii_isalnum(last_c)) { all_chars_domain = false; } @@ -2485,7 +2486,15 @@ rspamd_url_parse(struct rspamd_url *uri, if (all_chars_domain) { /* Additionally check for a numeric IP as we can have some number here... */ rspamd_url_maybe_regenerate_from_ip(uri, pool); - uri->tldlen = uri->hostlen; + + if (last_c == '.' && uri->hostlen > 1) { + /* Skip the last dot */ + uri->tldlen = uri->hostlen - 1; + } + else { + uri->tldlen = uri->hostlen; + } + uri->tldshift = uri->hostshift; is_whole_hostname_tld = true; } |