urlapi: fix redirect handling if CURLU_NO_GUESS_SCHEME is set

Verified by test 1967

Reported-by: Joshua Rogers
Closes #21721
This commit is contained in:
Daniel Stenberg 2026-05-21 23:00:55 +02:00
parent 8e549fbdd3
commit 7e350dd147
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 77 additions and 4 deletions

View file

@ -1731,8 +1731,9 @@ static CURLUcode set_url(CURLU *u, const char *url, size_t part_size,
return parseurl_and_replace(url, u, flags);
/* if the old URL is incomplete (we cannot get an absolute URL in
'oldurl'), replace the existing with the new */
uc = curl_url_get(u, CURLUPART_URL, &oldurl, flags);
'oldurl'), replace the existing with the new.
Always include "scheme://" to make the URL "complete" */
uc = curl_url_get(u, CURLUPART_URL, &oldurl, flags& ~CURLU_NO_GUESS_SCHEME);
if(uc == CURLUE_OUT_OF_MEMORY)
return uc;
else if(uc)