From: Vsevolod Stakhov Date: Wed, 15 Apr 2015 16:14:31 +0000 (+0100) Subject: Fix TLD detection. X-Git-Tag: 0.9.0~235 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c94da7bd85622fc0a7576bc3c94b635933fb0e7;p=thirdparty%2Frspamd.git Fix TLD detection. --- diff --git a/src/libserver/url.c b/src/libserver/url.c index 19e056c7a8..c31a727c7a 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; }