From: Vsevolod Stakhov Date: Wed, 16 Mar 2016 09:03:02 +0000 (+0000) Subject: [Fix] Improve diagnostic for url misdetection X-Git-Tag: 1.2.0~33 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=48b7558c1e745aa02ade2440d7eaebcdc7048b85;p=rspamd.git [Fix] Improve diagnostic for url misdetection --- diff --git a/src/libserver/url.c b/src/libserver/url.c index 4d0969a97..eeaf0eebe 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -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; } } diff --git a/src/libserver/url.h b/src/libserver/url.h index a4b61fc6d..4d38e3d79 100644 --- a/src/libserver/url.h +++ b/src/libserver/url.h @@ -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 {