diff options
Diffstat (limited to 'tests/libtest/lib1560.c')
-rw-r--r-- | tests/libtest/lib1560.c | 118 |
1 files changed, 88 insertions, 30 deletions
diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 1cc1a60ec..f09454c45 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -129,17 +129,21 @@ struct querycase { }; static const struct testcase get_parts_list[] ={ + {"https://user:password@example.net/get?this=and#but frag then", "", + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_FRAGMENT}, {"https://user:password@example.net/get?this=and what", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_QUERY}, {"https://user:password@example.net/ge t?this=and-what", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_PATH}, {"https://user:pass word@example.net/get?this=and-what", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_PASSWORD}, {"https://u ser:password@example.net/get?this=and-what", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_USER}, + {"imap://user:pass;opt ion@server/path", "", + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_LOGIN}, /* no space allowed in scheme */ {"htt ps://user:password@example.net/get?this=and-what", "", - CURLU_NON_SUPPORT_SCHEME|CURLU_ALLOW_SPACE, 0, CURLUE_MALFORMED_INPUT}, + CURLU_NON_SUPPORT_SCHEME|CURLU_ALLOW_SPACE, 0, CURLUE_BAD_SCHEME}, {"https://user:password@example.net/get?this=and what", "https | user | password | [13] | example.net | [15] | /get | " "this=and what | [17]", @@ -213,9 +217,9 @@ static const struct testcase get_parts_list[] ={ "com/color/?green#no-red", CURLU_DEFAULT_SCHEME, 0, CURLUE_OK }, {"http://[ab.be:1]/x", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_IPV6}, {"http://[ab.be]/x", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_IPV6}, /* URL without host name */ {"http://a:b@/x", "", CURLU_DEFAULT_SCHEME, 0, CURLUE_NO_HOST}, @@ -254,7 +258,7 @@ static const struct testcase get_parts_list[] ={ 0, 0, CURLUE_OK}, {"file://hello.html", "", - 0, 0, CURLUE_MALFORMED_INPUT}, + 0, 0, CURLUE_BAD_FILE_URL}, {"http://HO0_-st/", "http | [11] | [12] | [13] | HO0_-st | [15] | / | [16] | [17]", 0, 0, CURLUE_OK}, @@ -272,7 +276,7 @@ static const struct testcase get_parts_list[] ={ 0, 0, CURLUE_OK}, {"file:/", "file | [11] | [12] | [13] | [14] | [15] | | [16] | [17]", - 0, 0, CURLUE_MALFORMED_INPUT}, + 0, 0, CURLUE_BAD_FILE_URL}, {"file://127.0.0.1/hello.html", "file | [11] | [12] | [13] | [14] | [15] | /hello.html | [16] | [17]", 0, 0, CURLUE_OK}, @@ -295,9 +299,9 @@ static const struct testcase get_parts_list[] ={ "https | [11] | [12] | [13] | 127abc.com | [15] | / | [16] | [17]", CURLU_DEFAULT_SCHEME, 0, CURLUE_OK}, {"https:// example.com?check", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_HOSTNAME}, {"https://e x a m p l e.com?check", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_HOSTNAME}, {"https://example.com?check", "https | [11] | [12] | [13] | example.com | [15] | / | check | [17]", CURLU_DEFAULT_SCHEME, 0, CURLUE_OK}, @@ -357,7 +361,7 @@ static const struct testcase get_parts_list[] ={ CURLU_DEFAULT_SCHEME, 0, CURLUE_OK}, {"http:////user:password@example.com:1234/path/html?query=name#anchor", "", - CURLU_DEFAULT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_DEFAULT_SCHEME, 0, CURLUE_BAD_SLASHES}, {NULL, NULL, 0, 0, CURLUE_OK}, }; @@ -367,8 +371,8 @@ static const struct urltestcase get_url_list[] = { {"https://h%c", "https://h%25c/", 0, 0, CURLUE_OK}, {"https://%%%%%%", "https://%25%25%25%25%25%25/", 0, 0, CURLUE_OK}, {"https://%41", "https://A/", 0, 0, CURLUE_OK}, - {"https://%20", "", 0, 0, CURLUE_MALFORMED_INPUT}, - {"https://%41%0d", "", 0, 0, CURLUE_MALFORMED_INPUT}, + {"https://%20", "", 0, 0, CURLUE_BAD_HOSTNAME}, + {"https://%41%0d", "", 0, 0, CURLUE_BAD_HOSTNAME}, {"https://%25", "https://%25/", 0, 0, CURLUE_OK}, {"https://_%c0_", "https://_\xC0_/", 0, 0, CURLUE_OK}, {"https://_%c0_", "https://_%C0_/", 0, CURLU_URLENCODE, CURLUE_OK}, @@ -385,7 +389,7 @@ static const struct urltestcase get_url_list[] = { {"https://+127.0.0.1", "https://%2B127.0.0.1/", 0, CURLU_URLENCODE, CURLUE_OK}, {"https://127.-0.0.1", "https://127.-0.0.1/", 0, 0, CURLUE_OK}, - {"https://127.0. 1", "https://127.0.0.1/", 0, 0, CURLUE_MALFORMED_INPUT}, + {"https://127.0. 1", "https://127.0.0.1/", 0, 0, CURLUE_BAD_HOSTNAME}, {"https://1.0x1000000", "https://1.0x1000000/", 0, 0, CURLUE_OK}, {"https://1.2.3.256", "https://1.2.3.256/", 0, 0, CURLUE_OK}, {"https://1.2.3.4.5", "https://1.2.3.4.5/", 0, 0, CURLUE_OK}, @@ -398,10 +402,10 @@ static const struct urltestcase get_url_list[] = { /* 41 bytes scheme is not allowed */ {"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA://hostname/path", "", - CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_BAD_SCHEME}, {"https://[fe80::20c:29ff:fe9c:409b%]:1234", "", - 0, 0, CURLUE_MALFORMED_INPUT}, + 0, 0, CURLUE_BAD_IPV6}, {"https://[fe80::20c:29ff:fe9c:409b%25]:1234", "https://[fe80::20c:29ff:fe9c:409b%2525]:1234/", 0, 0, CURLUE_OK}, @@ -437,14 +441,14 @@ static const struct urltestcase get_url_list[] = { CURLU_GUESS_SCHEME, 0, CURLUE_OK}, {"HTTP://test/", "http://test/", 0, 0, CURLUE_OK}, {"http://HO0_-st..~./", "http://HO0_-st..~./", 0, 0, CURLUE_OK}, - {"http:/@example.com: 123/", "", 0, 0, CURLUE_MALFORMED_INPUT}, - {"http:/@example.com:123 /", "", 0, 0, CURLUE_MALFORMED_INPUT}, + {"http:/@example.com: 123/", "", 0, 0, CURLUE_BAD_PORT_NUMBER}, + {"http:/@example.com:123 /", "", 0, 0, CURLUE_BAD_PORT_NUMBER}, {"http:/@example.com:123a/", "", 0, 0, CURLUE_BAD_PORT_NUMBER}, - {"http://host/file\r", "", 0, 0, CURLUE_MALFORMED_INPUT}, - {"http://host/file\n\x03", "", 0, 0, CURLUE_MALFORMED_INPUT}, + {"http://host/file\r", "", 0, 0, CURLUE_BAD_PATH}, + {"http://host/file\n\x03", "", 0, 0, CURLUE_BAD_PATH}, {"htt\x02://host/file", "", - CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, - {" http://host/file", "", 0, 0, CURLUE_MALFORMED_INPUT}, + CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_BAD_SCHEME}, + {" http://host/file", "", 0, 0, CURLUE_BAD_SCHEME}, /* here the password ends at the semicolon and options is 'word' */ {"imap://user:pass;word@host/file", "imap://user:pass;word@host/file", @@ -464,7 +468,7 @@ static const struct urltestcase get_url_list[] = { 0, 0, CURLUE_OK}, {"file:./", "file://", - 0, 0, CURLUE_MALFORMED_INPUT}, + 0, 0, CURLUE_BAD_SCHEME}, {"http://example.com/hello/../here", "http://example.com/hello/../here", CURLU_PATH_AS_IS, 0, CURLUE_OK}, @@ -500,7 +504,7 @@ static const struct urltestcase get_url_list[] = { CURLU_DEFAULT_SCHEME, 0, CURLUE_OK}, {"example.com/path/html", "", - 0, 0, CURLUE_MALFORMED_INPUT}, + 0, 0, CURLUE_BAD_SCHEME}, {"http://user:password@example.com:1234/path/html?query=name#anchor", "http://user:password@example.com:1234/path/html?query=name#anchor", 0, 0, CURLUE_OK}, @@ -524,7 +528,7 @@ static const struct urltestcase get_url_list[] = { CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_OK}, {"custom-scheme://?expected=test-bad", "", - CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_MALFORMED_INPUT}, + CURLU_NON_SUPPORT_SCHEME, 0, CURLUE_NO_HOST}, {"custom-scheme://?expected=test-new-good", "custom-scheme:///?expected=test-new-good", CURLU_NON_SUPPORT_SCHEME | CURLU_NO_AUTHORITY, 0, CURLUE_OK}, @@ -565,7 +569,7 @@ static const struct setcase set_parts_list[] = { /* Set a 41 bytes scheme. That's too long so the old scheme remains set. */ "scheme=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbc,", "https://example.com/", - 0, CURLU_NON_SUPPORT_SCHEME, CURLUE_OK, CURLUE_MALFORMED_INPUT}, + 0, CURLU_NON_SUPPORT_SCHEME, CURLUE_OK, CURLUE_BAD_SCHEME}, {"https://example.com/", /* set a 40 bytes scheme */ "scheme=bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb,", @@ -586,7 +590,7 @@ static const struct setcase set_parts_list[] = { {"https://host:1234/", "port=56 78,", "https://host:1234/", - 0, 0, CURLUE_OK, CURLUE_MALFORMED_INPUT}, + 0, 0, CURLUE_OK, CURLUE_BAD_PORT_NUMBER}, {"https://host:1234/", "port=0,", "https://host:1234/", @@ -619,7 +623,7 @@ static const struct setcase set_parts_list[] = { {NULL, "scheme=https,host= ,path= ,user= ,password= ,query= ,fragment= ,", "[nothing]", - 0, CURLU_URLENCODE, CURLUE_OK, CURLUE_MALFORMED_INPUT}, + 0, CURLU_URLENCODE, CURLUE_OK, CURLUE_BAD_HOSTNAME}, {NULL, "scheme=https,host=foobar,path=/this /path /is /here,", "https://foobar/this%20/path%20/is%20/here", @@ -688,7 +692,7 @@ static const struct setcase set_parts_list[] = { "host=\"\",", "custom-scheme://host/", CURLU_NON_SUPPORT_SCHEME, CURLU_NON_SUPPORT_SCHEME, CURLUE_OK, - CURLUE_MALFORMED_INPUT}, + CURLUE_BAD_HOSTNAME}, {"custom-scheme://host", "host=\"\",", "custom-scheme:///", @@ -1164,10 +1168,64 @@ static int scopeid(void) return error; } +static int get_nothing(void) +{ + CURLU *u = curl_url(); + if(u) { + char *p; + CURLUcode rc; + + rc = curl_url_get(u, CURLUPART_SCHEME, &p, 0); + if(rc != CURLUE_NO_SCHEME) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_HOST, &p, 0); + if(rc != CURLUE_NO_HOST) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_USER, &p, 0); + if(rc != CURLUE_NO_USER) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_PASSWORD, &p, 0); + if(rc != CURLUE_NO_PASSWORD) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_OPTIONS, &p, 0); + if(rc != CURLUE_NO_OPTIONS) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_PATH, &p, 0); + if(rc != CURLUE_OK) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + else + curl_free(p); + + rc = curl_url_get(u, CURLUPART_QUERY, &p, 0); + if(rc != CURLUE_NO_QUERY) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_FRAGMENT, &p, 0); + if(rc != CURLUE_NO_FRAGMENT) + fprintf(stderr, "unexpected return code line %u\n", __LINE__); + + rc = curl_url_get(u, CURLUPART_ZONEID, &p, 0); + if(rc != CURLUE_OK) + fprintf(stderr, "unexpected return code %u on line %u\n", (int)rc, + __LINE__); + + curl_url_cleanup(u); + } + return 0; +} + int test(char *URL) { (void)URL; /* not used */ + if(get_nothing()) + return 7; + if(scopeid()) return 6; |