Fix join with rel part of " ". Add a few tests.

This commit is contained in:
Michael Drake 2012-11-02 10:54:34 +00:00
parent af2d9e8906
commit 9ab851a5a9
2 changed files with 13 additions and 0 deletions

View File

@ -136,6 +136,12 @@ static const struct test_pairs join_tests[] = {
{ "http://", "http:" }, { "http://", "http:" },
{ "http:/", "http:" }, { "http:/", "http:" },
{ "http:", "http:" }, { "http:", "http:" },
{ " ", "http://a/b/c/d;p?q" },
{ " ", "http://a/b/c/d;p?q" },
{ "/", "http://a/" },
{ " / ", "http://a/" },
{ " ? ", "http://a/b/c/d;p?" },
{ " h ", "http://a/b/c/h" },
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're /* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */ * testing normalisation in addition to joining */
/* [2] Using the strict parsers option */ /* [2] Using the strict parsers option */

View File

@ -264,6 +264,13 @@ static void nsurl__get_string_markers(const char * const url_s,
marker.scheme_end = marker.authority = marker.colon_first = marker.at = marker.scheme_end = marker.authority = marker.colon_first = marker.at =
marker.colon_last = marker.path = marker.start; marker.colon_last = marker.path = marker.start;
if (*pos == '\0') {
/* Nothing but whitespace, early exit */
marker.query = marker.fragment = marker.end = marker.path;
*markers = marker;
return;
}
/* Get scheme */ /* Get scheme */
if (isalpha(*pos)) { if (isalpha(*pos)) {
pos++; pos++;