summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-16 09:03:02 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-16 09:03:02 +0000
commit48b7558c1e745aa02ade2440d7eaebcdc7048b85 (patch)
treee0b3f6acf9567707e740e16e8912d4a6379263aa
parentcddd684078c732870fccc086d221c1ac45d8732c (diff)
downloadrspamd-48b7558c1e745aa02ade2440d7eaebcdc7048b85.tar.gz
rspamd-48b7558c1e745aa02ade2440d7eaebcdc7048b85.zip
[Fix] Improve diagnostic for url misdetection
-rw-r--r--src/libserver/url.c9
-rw-r--r--src/libserver/url.h4
2 files changed, 10 insertions, 3 deletions
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 {