diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-02 14:14:01 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-02 14:14:01 +0000 |
commit | 132da5d4b35335eb490c63f5d1ac889b1a71bfd0 (patch) | |
tree | 2fcfe0e7821ae14aa2cdc6038024ed03215acb39 /src | |
parent | b80ca7eb2fd2b7236e50d2297e42f779902384c2 (diff) | |
download | rspamd-132da5d4b35335eb490c63f5d1ac889b1a71bfd0.tar.gz rspamd-132da5d4b35335eb490c63f5d1ac889b1a71bfd0.zip |
Fix issues found by unit testing.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/url.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index b43189719..bdb59f699 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -1106,7 +1106,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, SET_U (u, UF_USERINFO); st = parse_at; } - else if (!is_atom (t)) { + else if (!g_ascii_isgraph (t)) { goto out; } p ++; @@ -1127,7 +1127,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, /* XXX: password is not stored */ st = parse_at; } - else if (!is_atom (t)) { + else if (!g_ascii_isgraph (t)) { goto out; } p ++; @@ -1151,6 +1151,13 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, * to apply some heuristic here */ st = parse_port_password; + } + else { + /* + * We can go only for parsing port here + */ + SET_U (u, UF_HOST); + st = parse_port; c = p + 1; } p ++; @@ -1186,7 +1193,9 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, /* XXX: that breaks urls with passwords starting with number */ st = parse_port; c = slash; + p --; SET_U (u, UF_HOST); + p ++; c = p; } else { @@ -1209,7 +1218,12 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, st = parse_suffix_slash; } else if (!g_ascii_isdigit (t)) { - goto out; + if (strict || !g_ascii_isspace (t)) { + goto out; + } + else { + goto set; + } } p ++; break; @@ -1445,7 +1459,7 @@ rspamd_url_parse (struct rspamd_url *uri, gchar *uristring, gsize len, uri->string = p; rspamd_unescape_uri (uri->string, uri->string, len); rspamd_str_lc (uri->string, uri->protocollen); - rspamd_str_lc (uri->host, uri->hostlen); + rspamd_str_lc_utf8 (uri->host, uri->hostlen); uri->protocol = PROTOCOL_UNKNOWN; |