diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-13 12:59:19 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-03-13 12:59:19 +0000 |
commit | 5c66e1f907dd39f0b24e7ffad16a02f022f427da (patch) | |
tree | 4afefe42a5a344c2c47497cb397bb293c1824493 /src/libserver | |
parent | 94f5ecf44d8fb3b6ad1436c4058840a1d86ddc41 (diff) | |
download | rspamd-5c66e1f907dd39f0b24e7ffad16a02f022f427da.tar.gz rspamd-5c66e1f907dd39f0b24e7ffad16a02f022f427da.zip |
Add workaround for certain types of urls.
Diffstat (limited to 'src/libserver')
-rw-r--r-- | src/libserver/url.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c index bdb59f699..53948ba89 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -1247,6 +1247,9 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, } else if (!is_urlsafe (t)) { if (strict) { + if (g_ascii_isspace (t)) { + goto set; + } goto out; } else { @@ -1265,6 +1268,9 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, } else if (!is_urlsafe (t)) { if (strict) { + if (g_ascii_isspace (t)) { + goto set; + } goto out; } else { @@ -1276,6 +1282,9 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len, case parse_part: if (!is_urlsafe (t)) { if (strict) { + if (g_ascii_isspace (t)) { + goto set; + } goto out; } else { @@ -1352,6 +1361,7 @@ rspamd_url_parse (struct rspamd_url *uri, gchar *uristring, gsize len, { struct http_parser_url u; gchar *p, *comp; + const gchar *end; guint i, complen, ret; const struct { @@ -1403,20 +1413,26 @@ rspamd_url_parse (struct rspamd_url *uri, gchar *uristring, gsize len, if (len > sizeof ("mailto:") - 1) { /* For mailto: urls we also need to add slashes to make it a valid URL */ if (g_ascii_strncasecmp (p, "mailto:", sizeof ("mailto:") - 1) == 0) { - ret = rspamd_mailto_parse (&u, uristring, len, NULL); + ret = rspamd_mailto_parse (&u, uristring, len, &end); } else { - ret = rspamd_web_parse (&u, uristring, len, NULL, TRUE); + ret = rspamd_web_parse (&u, uristring, len, &end, TRUE); } } else { - ret = rspamd_web_parse (&u, uristring, len, NULL, TRUE); + ret = rspamd_web_parse (&u, uristring, len, &end, TRUE); } if (ret != 0) { return URI_ERRNO_BAD_FORMAT; } + if (end > uristring && (guint)(end - uristring) != len) { + /* We have extra data at the end of uri, so we are ignoring it for now */ + p = rspamd_mempool_alloc (pool, end - uristring + 1); + rspamd_strlcpy (p, uristring, end - uristring + 1); + } + for (i = 0; i < UF_MAX; i ++) { if (u.field_set & (1 << i)) { comp = p + u.field_data[i].off; |