aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-22 17:43:02 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-04-22 17:43:02 +0100
commita2595d668f2f095c56cbc55aee9f0bbea8efb2f9 (patch)
treee983c5ffdffbbe1090b0b447c59e9578d13c766f /src/libserver
parent526cb1747366be73f4eec7a3ac9c9aa6aa71d982 (diff)
downloadrspamd-a2595d668f2f095c56cbc55aee9f0bbea8efb2f9.tar.gz
rspamd-a2595d668f2f095c56cbc55aee9f0bbea8efb2f9.zip
Parse ipv6 URL's.
Diffstat (limited to 'src/libserver')
-rw-r--r--src/libserver/url.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libserver/url.c b/src/libserver/url.c
index cfe925ea3..43ef9f9b1 100644
--- a/src/libserver/url.c
+++ b/src/libserver/url.c
@@ -557,6 +557,7 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
parse_password_start,
parse_password,
parse_domain,
+ parse_ipv6,
parse_port_password,
parse_port,
parse_suffix_slash,
@@ -610,6 +611,36 @@ rspamd_web_parse (struct http_parser_url *u, const gchar *str, gsize len,
c = p;
st = parse_domain;
slash = p;
+
+ if (*p == '[') {
+ st = parse_ipv6;
+ p ++;
+ c = p;
+ }
+ break;
+ case parse_ipv6:
+ if (t == ']') {
+ if (p - c == 0) {
+ goto out;
+ }
+ SET_U (u, UF_HOST);
+ p ++;
+
+ if (*p == ':') {
+ st = parse_port;
+ c = p + 1;
+ }
+ else if (*p == '/') {
+ st = parse_path;
+ c = p + 1;
+ }
+ else if (p != last) {
+ goto out;
+ }
+ }
+ else {
+ p ++;
+ }
break;
case parse_user:
if (t == ':') {
@@ -861,6 +892,15 @@ set:
}
ret = 0;
break;
+ case parse_ipv6:
+ if (t != ']') {
+ ret = 1;
+ }
+ else {
+ /* e.g. http://[::] */
+ ret = 0;
+ }
+ break;
default:
/* Error state */
ret = 1;