From 1c7f8cac9ea328647558a42f24206f3ad5da24b7 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Tue, 4 Dec 2012 15:31:09 -0500 Subject: [PATCH] Fix IPv6 address parsing. Fixes #133. --- http_parser.c | 2 +- test.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/http_parser.c b/http_parser.c index b13a28c..c710982 100644 --- a/http_parser.c +++ b/http_parser.c @@ -1962,7 +1962,7 @@ http_parse_host_char(enum http_host_state s, const char ch) { /* FALLTHROUGH */ case s_http_host_v6_start: - if (IS_HEX(ch) || ch == ':') { + if (IS_HEX(ch) || ch == ':' || ch == '.') { return s_http_host_v6; } diff --git a/test.c b/test.c index acd43b8..d87f68e 100644 --- a/test.c +++ b/test.c @@ -2214,6 +2214,25 @@ const struct url_test url_tests[] = ,.rv=0 } +, {.name="ipv4 in ipv6 address" + ,.url="http://[2001:0000:0000:0000:0000:0000:1.9.1.1]/" + ,.is_connect=0 + ,.u= + {.field_set=(1 << UF_SCHEMA) | (1 << UF_HOST) | (1 << UF_PATH) + ,.port=0 + ,.field_data= + {{ 0, 4 } /* UF_SCHEMA */ + ,{ 8, 37 } /* UF_HOST */ + ,{ 0, 0 } /* UF_PORT */ + ,{ 46, 1 } /* UF_PATH */ + ,{ 0, 0 } /* UF_QUERY */ + ,{ 0, 0 } /* UF_FRAGMENT */ + ,{ 0, 0 } /* UF_USERINFO */ + } + } + ,.rv=0 + } + , {.name="extra ? in query string" ,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css,"