]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Improve diagnostic for url misdetection
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Mar 2016 09:03:02 +0000 (09:03 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Wed, 16 Mar 2016 09:03:02 +0000 (09:03 +0000)
src/libserver/url.c
src/libserver/url.h

index 4d0969a9795440df7d3c1451bfcdedcf3d644897..eeaf0eebe49cecaa36d9e14b12dbc443703ab74a 100644 (file)
@@ -323,7 +323,12 @@ rspamd_url_strerror (enum uri_errno err)
                        return "Invalid symbols encoded";
                case URI_ERRNO_INVALID_PORT:
                        return "Port number is bad";
+               case URI_ERRNO_TLD_MISSING:
+                       return "TLD part is not detected";
+               case URI_ERRNO_HOST_MISSING:
+                       return "Host part is missing";
        }
+
        return NULL;
 }
 
@@ -1501,7 +1506,7 @@ rspamd_url_parse (struct rspamd_url *uri, gchar *uristring, gsize len,
        uri->port = u.port;
 
        if (!uri->hostlen) {
-               return URI_ERRNO_BAD_FORMAT;
+               return URI_ERRNO_HOST_MISSING;
        }
 
        /* Now decode url symbols */
@@ -1552,7 +1557,7 @@ rspamd_url_parse (struct rspamd_url *uri, gchar *uristring, gsize len,
                        rspamd_tld_trie_callback, uri, &state, true) == 0) {
                /* Ignore URL's without TLD if it is not a numeric URL */
                if (!rspamd_url_is_ip (uri, pool)) {
-                       return URI_ERRNO_BAD_FORMAT;
+                       return URI_ERRNO_TLD_MISSING;
                }
        }
 
index a4b61fc6d826d715b4bf3bb46d549192c88e4d0a..4d38e3d79207cdc9d5267ec3434bb99c4718894f 100644 (file)
@@ -49,7 +49,9 @@ enum uri_errno {
        URI_ERRNO_INVALID_PROTOCOL, /* No protocol was found */
        URI_ERRNO_INVALID_PORT,     /* Port number is bad */
        URI_ERRNO_BAD_ENCODING, /* Bad characters encoding */
-       URI_ERRNO_BAD_FORMAT
+       URI_ERRNO_BAD_FORMAT,
+       URI_ERRNO_TLD_MISSING,
+       URI_ERRNO_HOST_MISSING
 };
 
 enum rspamd_url_protocol {