Return nonzero on parsing empty url.

Fixes: https://github.com/nodejs/http-parser/issues/414
PR-URL: https://github.com/nodejs/http-parser/pull/424
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
make-http-max-header-size-gyp-configurable
Welling Guzman 7 years ago committed by Ben Noordhuis
parent 2ed7527795
commit 31232735c6

@ -2314,6 +2314,10 @@ http_parser_parse_url(const char *buf, size_t buflen, int is_connect,
enum http_parser_url_fields uf, old_uf;
int found_at = 0;
if (buflen == 0) {
return 1;
}
u->port = u->field_set = 0;
s = is_connect ? s_req_server_start : s_req_spaces_before_url;
old_uf = UF_MAX;

@ -3250,6 +3250,24 @@ const struct url_test url_tests[] =
,.rv=1 /* s_dead */
}
, {.name="empty url"
,.url=""
,.is_connect=0
,.rv=1
}
, {.name="NULL url"
,.url=NULL
,.is_connect=0
,.rv=1
}
, {.name="full of spaces url"
,.url=" "
,.is_connect=0
,.rv=1
}
#if HTTP_PARSER_STRICT
, {.name="tab in URL"
@ -3334,7 +3352,7 @@ test_parse_url (void)
memset(&u, 0, sizeof(u));
rv = http_parser_parse_url(test->url,
strlen(test->url),
test->url ? strlen(test->url) : 0,
test->is_connect,
&u);

Loading…
Cancel
Save