From dc36f0d70c561faabc69b3ba314c067cef2b8f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?T=C3=B6r=C3=B6k=20Edvin?= Date: Wed, 1 Oct 2008 09:56:54 +0000 Subject: [PATCH] strip spaces from URL before checking that it is a URL git-svn: trunk@4215 --- libclamav/phishcheck.c | 6 +++++- unit_tests/check_regex.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libclamav/phishcheck.c b/libclamav/phishcheck.c index 54fcd57c4..42b7962ab 100644 --- a/libclamav/phishcheck.c +++ b/libclamav/phishcheck.c @@ -995,10 +995,12 @@ static inline int validate_uri_ialpha(const char *start, const char *end) */ static int isURL(const struct phishcheck* pchk,const char* URL, int accept_anyproto) { + size_t len; const char *start = NULL, *p, *q; if(!URL) return 0; + while (*URL == ' ') URL++; switch (URL[0]) { case 'h': if (strncmp(URL, https, https_len) == 0) @@ -1045,7 +1047,9 @@ static int isURL(const struct phishcheck* pchk,const char* URL, int accept_anypr } while(q); if (p == start) /* must have at least one dot in the URL */ return 0; - return !!in_tld_set(p, strlen(p)); + len = strlen(p); + while (len > 1 && p[len-1] == ' ') len--; + return !!in_tld_set(p, len); } /* diff --git a/unit_tests/check_regex.c b/unit_tests/check_regex.c index 7f4e9dfc8..a3ae43be2 100644 --- a/unit_tests/check_regex.c +++ b/unit_tests/check_regex.c @@ -172,7 +172,10 @@ static const struct rtest { } rtests[] = { {NULL,"http://fake.example.com","=====key.com",0}, {NULL,"http://key.com","=====key.com",2}, + {NULL," http://key.com","=====key.com",2}, {NULL,"http://key.com@fake.example.com","key.com",0}, + {NULL," http://key.com@fake.example.com","key.com",0}, + {NULL," http://key.com@fake.example.com ","key.com",0}, /* entry taken from .wdb with a / appended */ {".+\\.ebayrtm\\.com([/?].*)?:.+\\.ebay\\.(de|com|co\\.uk)([/?].*)?/", "http://srx.main.ebayrtm.com",