diff options
-rw-r--r-- | lib/urlapi.c | 8 | ||||
-rw-r--r-- | tests/libtest/lib1560.c | 20 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/urlapi.c b/lib/urlapi.c index 1334236b2..a51428404 100644 --- a/lib/urlapi.c +++ b/lib/urlapi.c @@ -849,14 +849,14 @@ static CURLUcode seturl(const char *url, CURLU *u, unsigned int flags) if(junkscan(path)) return CURLUE_MALFORMED_INPUT; + fragment = strchr(path, '#'); + if(fragment) + *fragment++ = 0; + query = strchr(path, '?'); if(query) *query++ = 0; - fragment = strchr(query?query:path, '#'); - if(fragment) - *fragment++ = 0; - if(!path[0]) /* if there's no path set, unset */ path = NULL; diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index d161423e3..7f8accc7d 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -140,6 +140,26 @@ static struct testcase get_parts_list[] ={ "file | [11] | [12] | [13] | [14] | [15] | C:\\programs\\foo | [16] | [17]", CURLU_DEFAULT_SCHEME, 0, CURLUE_OK}, #endif + {"https://example.com/color/#green?no-black", + "https | [11] | [12] | [13] | example.com | [15] | /color/ | [16] | " + "green?no-black", + CURLU_DEFAULT_SCHEME, 0, CURLUE_OK }, + {"https://example.com/color/#green#no-black", + "https | [11] | [12] | [13] | example.com | [15] | /color/ | [16] | " + "green#no-black", + CURLU_DEFAULT_SCHEME, 0, CURLUE_OK }, + {"https://example.com/color/?green#no-black", + "https | [11] | [12] | [13] | example.com | [15] | /color/ | green | " + "no-black", + CURLU_DEFAULT_SCHEME, 0, CURLUE_OK }, + {"https://example.com/#color/?green#no-black", + "https | [11] | [12] | [13] | example.com | [15] | / | [16] | " + "color/?green#no-black", + CURLU_DEFAULT_SCHEME, 0, CURLUE_OK }, + {"https://example.#com/color/?green#no-black", + "https | [11] | [12] | [13] | example. | [15] | / | [16] | " + "com/color/?green#no-black", + CURLU_DEFAULT_SCHEME, 0, CURLUE_OK }, {"http://[ab.be:1]/x", "", CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, {"http://[ab.be]/x", "", |