curl: do NOT append file name to path for upload when there's a query

Added test 425 to verify.

Reported-by: Dirk Rosenkranz
Bug: https://curl.se/mail/archive-2023-04/0008.html
Closes #10969
This commit is contained in:
Daniel Stenberg 2023-04-14 23:46:51 +02:00
parent 7ed010ce21
commit 54ac447b11
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 62 additions and 2 deletions

View file

@ -95,6 +95,7 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename)
CURLUcode uerr;
CURLU *uh = curl_url();
char *path = NULL;
char *query = NULL;
if(uh) {
char *ptr;
uerr = curl_url_set(uh, CURLUPART_URL, *inurlp,
@ -108,7 +109,13 @@ CURLcode add_file_name_to_url(CURL *curl, char **inurlp, const char *filename)
result = urlerr_cvt(uerr);
goto fail;
}
uerr = curl_url_get(uh, CURLUPART_QUERY, &query, 0);
if(query) {
curl_free(query);
curl_free(path);
curl_url_cleanup(uh);
return CURLE_OK;
}
ptr = strrchr(path, '/');
if(!ptr || !*++ptr) {
/* The URL path has no file name part, add the local file name. In order