strip spaces from URL before checking that it is a URL

git-svn: trunk@4215
0.95
Török Edvin 17 years ago
parent 048725d0d6
commit dc36f0d70c
  1. 6
      libclamav/phishcheck.c
  2. 3
      unit_tests/check_regex.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);
}
/*

@ -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",

Loading…
Cancel
Save