aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-15 17:14:31 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-15 17:14:31 +0100
commit0c94da7bd85622fc0a7576bc3c94b635933fb0e7 (patch)
tree303d91fa851077d05dc57218b22ff52f98641e5a /src
parent99e2a7ffa260440922c9756084b7badd73409701 (diff)
downloadrspamd-0c94da7bd85622fc0a7576bc3c94b635933fb0e7.tar.gz
rspamd-0c94da7bd85622fc0a7576bc3c94b635933fb0e7.zip
Fix TLD detection.
Diffstat (limited to 'src')
-rw-r--r--src/libserver/url.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c
index 19e056c7a..c31a727c7 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -894,16 +894,17 @@ rspamd_tld_trie_callback (int strnum, int textpos, void *context)
ndots = 2;
}
- pos = url->host + textpos;
+ pos = url->host + textpos - pat->len;
start = url->host;
- if (*pos != '.' || pos + pat->len != url->host + url->hostlen) {
+ if (*pos != '.' || textpos != (gint)url->hostlen) {
/* Something weird has been found */
return 0;
}
/* Now we need to find top level domain */
p = pos - 1;
+ pos = start;
while (p >= start && ndots > 0) {
if (*p == '.') {
ndots --;
@@ -913,7 +914,7 @@ rspamd_tld_trie_callback (int strnum, int textpos, void *context)
p --;
}
- if (ndots == 0) {
+ if (ndots == 0 || p == start - 1) {
url->tld = (gchar *)pos;
url->tldlen = url->host + url->hostlen - pos;
}