Skip to content

Commit

Permalink
allow extra ? at the beginning of a query_string.
Browse files Browse the repository at this point in the history
fixes joyent/http-parser issue nodejs#25
  • Loading branch information
dgwynne authored and bnoordhuis committed Feb 18, 2012
1 parent 8da60bc commit 6756842
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
19 changes: 2 additions & 17 deletions http_parser.c
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions test.c
Expand Up @@ -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<<UF_SCHEMA) | (1<<UF_HOST) | (1<<UF_PATH) | (1<<UF_QUERY)
,.port=0
,.field_data=
{{ 0, 4 } /* UF_SCHEMA */
,{ 7, 10 } /* UF_HOST */
,{ 0, 0 } /* UF_PORT */
,{ 17, 12 } /* UF_PATH */
,{ 30,187 } /* UF_QUERY */
,{ 0, 0 } /* UF_FRAGMENT */
}
}
,.rv=0
}

, {.name="proxy empty host"
,.url="http://:443/"
,.is_connect=1
Expand Down

0 comments on commit 6756842

Please sign in to comment.