]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Ignore completely damaged urls
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Mar 2019 20:18:57 +0000 (20:18 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 4 Mar 2019 20:18:57 +0000 (20:18 +0000)
src/libserver/html.c
src/libserver/url.c

index 7da18cdfea304d656a50c958ab9b8771f1ae45ff..63638d28b0693c57a312d2c03bcef0540db1f96b 100644 (file)
@@ -1441,7 +1441,9 @@ rspamd_html_process_url (rspamd_mempool_t *pool, const gchar *start, guint len,
 
        rc = rspamd_url_parse (url, decoded, dlen, pool, RSPAMD_URL_PARSE_HREF);
 
-       if (rc == URI_ERRNO_OK) {
+       /* Filter some completely damaged urls */
+       if (rc == URI_ERRNO_OK && url->hostlen > 0 &&
+               !((url->flags & RSPAMD_URL_FLAG_OBSCURED) && (url->protocol & PROTOCOL_UNKNOWN))) {
                url->flags |= saved_flags;
 
                if (has_bad_chars) {
index 6b4a0d2d02290e74a871a0c6dbba9affdfeefeee..f860eec0ce187206a26151ce02d3b2210c690b1a 100644 (file)
@@ -1388,7 +1388,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
        /* Parse remaining */
        switch (st) {
                case parse_domain:
-                       if (p - c == 0) {
+                       if (p - c == 0 || !is_domain (*(p - 1)) || !is_domain (*c)) {
                                goto out;
                        }
                        SET_U (u, UF_HOST);
@@ -2032,7 +2032,7 @@ rspamd_url_parse (struct rspamd_url *uri,
                }
                else {
                        /* Hack, hack, hack */
-                       uri->protocol = PROTOCOL_HTTP;
+                       uri->protocol = PROTOCOL_UNKNOWN;
                }
        }