← Commit list

780ccb256e

tiymat
tiymat
2026-05-31
SUCCESS Duration: 270s

Subject

urlapi: drop base fragment on empty redirect

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/urlapi.c+5 -2
@@ -1721,8 +1721,11 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size,
and this is a redirect */
uc = curl_url_get(u, CURLUPART_URL, &oldurl, flags);
if(!uc) {
- /* success, meaning the "" is a fine relative URL, but nothing
- changes */
+ /* success, meaning the "" is a fine relative URL, and the new URL
+ inherits scheme/authority/path/query, but not fragment, from the
+ existing URL (RFC 3986 section 5.2.2) */
+ curlx_safefree(u->fragment);
+ u->fragment_present = FALSE;
curlx_free(oldurl);
return CURLUE_OK;
}
tests/data/test1560+1 -1
@@ -37,7 +37,7 @@ lib%TESTNUMBER
success
</stdout>
<limits>
-Allocations: 3200
+Allocations: 3250
</limits>
</verify>
</testcase>
tests/libtest/lib1560.c+27 -0
@@ -1356,6 +1356,33 @@ static const struct redircase set_url_list[] = {
"", /* blank redirect */
"https://example.com/",
0, 0, CURLUE_OK },
+ {"file:///test?test#test",
+ "", "file:///test?test",
+ 0, 0, CURLUE_OK},
+ {"https://example.com/path?query#frag",
+ "", "https://example.com/path?query",
+ 0, 0, CURLUE_OK},
+ {"ftp://example.com/dir/file#anchor",
+ "", "ftp://example.com/dir/file",
+ 0, 0, CURLUE_OK},
+ {"http://example.com/path#frag",
+ "", "http://example.com/path",
+ 0, 0, CURLUE_OK},
+ {"http://example.com/#frag",
+ "", "http://example.com/",
+ 0, 0, CURLUE_OK},
+ {"http://user:[email protected]/path?query#frag",
+ "", "http://user:[email protected]/path?query",
+ 0, 0, CURLUE_OK},
+ {"http://example.com:8080/path?query#frag",
+ "", "http://example.com:8080/path?query",
+ 0, 0, CURLUE_OK},
+ {"https://user:[email protected]:8443/path?query#frag",
+ "", "https://user:[email protected]:8443/path?query",
+ 0, 0, CURLUE_OK},
+ {"http://[::1]/path#frag",
+ "", "http://[::1]/path",
+ 0, 0, CURLUE_OK},
{"http://firstplace.example.com/want/1314",
"//somewhere.example.com/reply/1314",
"http://somewhere.example.com/reply/1314",