From 67568421e9ede487860aa376889f68e0eeb626ed Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Sat, 18 Feb 2012 15:41:41 +1000 Subject: [PATCH] allow extra ? at the beginning of a query_string. fixes joyent/http-parser issue #25 --- http_parser.c | 19 ++----------------- test.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/http_parser.c b/http_parser.c index 5a11de0..14b4d71 100644 --- a/http_parser.c +++ b/http_parser.c @@ -535,30 +535,15 @@ parse_url_char(enum state s, const char ch) break; case s_req_query_string_start: - if (IS_URL_CHAR(ch)) { - return s_req_query_string; - } - - switch (ch) { - case '?': - /* XXX ignore extra '?' ... is this right? */ - return s; - - case '#': - return s_req_fragment_start; - } - - break; - case s_req_query_string: if (IS_URL_CHAR(ch)) { - return s; + return s_req_query_string; } switch (ch) { case '?': /* allow extra '?' in query string */ - return s; + return s_req_query_string; case '#': return s_req_fragment_start; diff --git a/test.c b/test.c index e3a6788..4cbb361 100644 --- a/test.c +++ b/test.c @@ -1985,6 +1985,24 @@ const struct url_test url_tests[] = ,.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,fp-sub-min.css,fp-gdp4p-min.css,fp-css3-min.css,fp-misc-min.css?t=20101022.css" + ,.is_connect=0 + ,.u= + {.field_set=(1<