urlapi: fix redirect from file:// with query, and simplify

- fix redirect from file:// URL with query part
- find_host_sep() simplify
- urlencode_str() simplify
- redirect_url() simplify
- made more const char *
- add more redirect URL test cases to test 1560

Closes #16498
This commit is contained in:
Daniel Stenberg 2025-02-26 11:13:36 +01:00
parent c028a243f2
commit bc24c60512
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 97 additions and 106 deletions

View file

@ -1143,6 +1143,25 @@ static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags)
}
static const struct redircase set_url_list[] = {
{"http://firstplace.example.com/want/1314",
"//somewhere.example.com/reply/1314",
"http://somewhere.example.com/reply/1314",
0, 0, CURLUE_OK },
{"http://127.0.0.1:46383/want?uri=http://anything/276?secondq/276",
"data/2760002.txt?coolsite=http://anotherurl/?a_second/2760002",
"http://127.0.0.1:46383/"
"data/2760002.txt?coolsite=http://anotherurl/?a_second/2760002",
0, 0, CURLUE_OK },
{"file:///basic#", "#yay",
"file:///basic#yay", 0, 0, CURLUE_OK},
{"file:///basic", "?yay",
"file:///basic?yay", 0, 0, CURLUE_OK},
{"file:///basic?", "?yay",
"file:///basic?yay", 0, 0, CURLUE_OK},
{"file:///basic?hello", "#frag",
"file:///basic?hello#frag", 0, 0, CURLUE_OK},
{"file:///basic?hello", "?q",
"file:///basic?q", 0, 0, CURLUE_OK},
{"http://example.org#withs/ash", "/moo#frag",
"http://example.org/moo#frag",
0, 0, CURLUE_OK},