Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Commit

Permalink
Fix IPv6 address parsing.
Browse files Browse the repository at this point in the history
Fixes #133.
  • Loading branch information
emberian authored and bnoordhuis committed Dec 5, 2012
1 parent cd01361 commit 1c7f8ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion http_parser.c
Expand Up @@ -1962,7 +1962,7 @@ http_parse_host_char(enum http_host_state s, const char ch) {


/* FALLTHROUGH */ /* FALLTHROUGH */
case s_http_host_v6_start: case s_http_host_v6_start:
if (IS_HEX(ch) || ch == ':') { if (IS_HEX(ch) || ch == ':' || ch == '.') {
return s_http_host_v6; return s_http_host_v6;
} }


Expand Down
19 changes: 19 additions & 0 deletions test.c
Expand Up @@ -2214,6 +2214,25 @@ const struct url_test url_tests[] =
,.rv=0 ,.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" , {.name="extra ? in query string"
,.url="http://a.tbcdn.cn/p/fp/2010c/??fp-header-min.css,fp-base-min.css," ,.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," "fp-channel-min.css,fp-product-min.css,fp-mall-min.css,fp-category-min.css,"
Expand Down

0 comments on commit 1c7f8ca

Please sign in to comment.