diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2012-11-02 10:54:34 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2012-11-02 10:54:34 +0000 |
commit | 9ab851a5a9f951a8d2e7e285489245bee2cd0303 (patch) | |
tree | 43f66df48e8e5397de2af81dbc8a0e2024b6bec8 | |
parent | af2d9e8906d1d439c0c4319298843c40047dd256 (diff) | |
download | netsurf-9ab851a5a9f951a8d2e7e285489245bee2cd0303.tar.gz netsurf-9ab851a5a9f951a8d2e7e285489245bee2cd0303.tar.bz2 |
Fix join with rel part of " ". Add a few tests.
-rw-r--r-- | test/nsurl.c | 6 | ||||
-rw-r--r-- | utils/nsurl.c | 7 |
2 files changed, 13 insertions, 0 deletions
diff --git a/test/nsurl.c b/test/nsurl.c index 20109f8fb..66bc05780 100644 --- a/test/nsurl.c +++ b/test/nsurl.c @@ -136,6 +136,12 @@ static const struct test_pairs join_tests[] = { { "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 * testing normalisation in addition to joining */ /* [2] Using the strict parsers option */ diff --git a/utils/nsurl.c b/utils/nsurl.c index 8c525452a..18577b65d 100644 --- a/utils/nsurl.c +++ b/utils/nsurl.c @@ -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.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 */ if (isalpha(*pos)) { pos++; |