diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-25 18:52:36 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-02-25 18:52:36 +0000 |
commit | 784bd1c3e3a30d6b89b832af2861b0efb11f2245 (patch) | |
tree | f4c9016ae2ab16c878ded605df3dd4a3e8c42422 /src/libserver/url.c | |
parent | 4184776a1744bfa1e73eac80e8126573d8aae0f0 (diff) | |
download | rspamd-784bd1c3e3a30d6b89b832af2861b0efb11f2245.tar.gz rspamd-784bd1c3e3a30d6b89b832af2861b0efb11f2245.zip |
[Minor] Fix some more tld issues and tld tests
Diffstat (limited to 'src/libserver/url.c')
-rw-r--r-- | src/libserver/url.c | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index 0407490d8..3c3dc4546 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -129,7 +129,6 @@ struct url_matcher { url_match_t *match); gint flags; - gsize patlen; }; static gboolean url_file_start (struct url_callback_data *cb, @@ -175,44 +174,44 @@ static gboolean url_tel_end (struct url_callback_data *cb, struct url_matcher static_matchers[] = { /* Common prefixes */ {"file://", "", url_file_start, url_file_end, - 0, 0}, + 0}, {"file:\\\\", "", url_file_start, url_file_end, - 0, 0}, + 0}, {"ftp://", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"ftp:\\\\", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"sftp://", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"http:", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"https:", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"news://", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"nntp://", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"telnet://", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"tel:", "", url_tel_start, url_tel_end, - 0, 0}, + 0}, {"webcal://", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"mailto:", "", url_email_start, url_email_end, - 0, 0}, + 0}, {"callto:", "", url_tel_start, url_tel_end, - 0, 0}, + 0}, {"h323:", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"sip:", "", url_web_start, url_web_end, - 0, 0}, + 0}, {"www.", "http://", url_web_start, url_web_end, - URL_FLAG_NOHTML, 0}, + URL_FLAG_NOHTML}, {"ftp.", "ftp://", url_web_start, url_web_end, - URL_FLAG_NOHTML, 0}, + URL_FLAG_NOHTML}, /* Likely emails */ {"@", "mailto://", url_email_start, url_email_end, - URL_FLAG_NOHTML, 0} + URL_FLAG_NOHTML} }; struct url_callback_data { @@ -461,7 +460,7 @@ rspamd_url_parse_tld_file (const gchar *fname, RSPAMD_MULTIPATTERN_TLD|RSPAMD_MULTIPATTERN_ICASE|RSPAMD_MULTIPATTERN_UTF8); m.pattern = rspamd_multipattern_get_pattern (url_scanner->search_trie, rspamd_multipattern_get_npatterns (url_scanner->search_trie) - 1); - m.patlen = strlen (m.pattern); + g_array_append_val (url_scanner->matchers, m); } @@ -488,8 +487,6 @@ rspamd_url_add_static_matchers (struct url_match_scanner *sc) static_matchers[i].pattern, RSPAMD_MULTIPATTERN_ICASE|RSPAMD_MULTIPATTERN_UTF8); } - - static_matchers[i].patlen = strlen (static_matchers[i].pattern); } g_array_append_vals (sc->matchers, static_matchers, n); @@ -1511,14 +1508,15 @@ rspamd_tld_trie_callback (struct rspamd_multipattern *mp, struct url_matcher *matcher; const gchar *start, *pos, *p; struct rspamd_url *url = context; - gint ndots = 1; + gint ndots; matcher = &g_array_index (url_scanner->matchers, struct url_matcher, strnum); + ndots = 1; if (matcher->flags & URL_FLAG_STAR_MATCH) { /* Skip one more tld component */ - ndots = 2; + ndots ++; } pos = text + match_start; @@ -2277,6 +2275,9 @@ rspamd_tld_trie_find_callback (struct rspamd_multipattern *mp, ndots--; pos = p + 1; } + else { + pos = p; + } p--; } |