From c7cf4d68dbf5adb173f5a7391833cc9df8e2b4dd Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 14 Oct 2016 12:22:17 +0100 Subject: [PATCH] [Fix] Fix some cases of TLD urls detector --- src/libserver/url.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libserver/url.c b/src/libserver/url.c index 81908c41a4..75b173c44c 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -1809,6 +1809,7 @@ url_tld_end (struct url_callback_data *cb, url_match_t *match) { const gchar *p; + gboolean ret = FALSE; p = pos + match->m_len; @@ -1822,12 +1823,12 @@ url_tld_end (struct url_callback_data *cb, p = match->m_begin; /* Check common prefix */ if (g_ascii_strncasecmp (p, "http://", sizeof ("http://") - 1) == 0) { - return url_web_end (cb, + ret = url_web_end (cb, match->m_begin + sizeof ("http://") - 1, match); } else { - return url_web_end (cb, match->m_begin, match); + ret = url_web_end (cb, match->m_begin, match); } } @@ -1836,12 +1837,19 @@ url_tld_end (struct url_callback_data *cb, if (p < cb->end) { if (g_ascii_isspace (*p) || *p == '/' || *p == '?' || *p == ':') { - return url_web_end (cb, match->m_begin, match); + ret = url_web_end (cb, match->m_begin, match); } } } - return FALSE; + if (ret) { + /* Check sanity of match found */ + if (match->m_begin + match->m_len <= pos) { + return FALSE; + } + } + + return ret; } static gboolean -- 2.47.3