Vsevolod Stakhov
2 years ago
No known key found for this signature in database
GPG Key ID: 7647B6790081437
2 changed files with
21 additions and
2 deletions
-
src/libserver/url.c
-
test/lua/unit/url.lua
|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
@ -148,6 +148,16 @@ context("URL check functions", function() |
|
|
|
host = "63.143.41.164", |
|
|
|
path = "pro/au.html", |
|
|
|
} }, |
|
|
|
{ |
|
|
|
"http://localhost", true, { |
|
|
|
host = "localhost", |
|
|
|
tld = "localhost", |
|
|
|
} }, |
|
|
|
{ |
|
|
|
"http://localhost.", true, { |
|
|
|
host = "localhost.", |
|
|
|
tld = "localhost", |
|
|
|
} }, |
|
|
|
} |
|
|
|
|
|
|
|
-- Some cases from https://code.google.com/p/google-url/source/browse/trunk/src/url_canon_unittest.cc |
|
|
|