Hi all, when recently trying out the libcurl-url API, I came across some
behavior which seems buggy to me: when copying a URL using curl_url_dup,
the zone ID is not copied into the new URL.
I wouldn't expect that this would be intended behavior (the curl_url_dup
man page specifies that all the contents of the CURLU handle are copied,
and does not note any exceptions). Could anyone confirm that this is
indeed (not) intended behaviour?
A small program to reproduce this behavior is in the attachments. I
would expect its output to be this:
Original: http://[2a04:4e42:e00::347%25eth0]/
Parsed: http://[2a04:4e42:e00::347%25eth0]/
Copy: http://[2a04:4e42:e00::347%25eth0]/
But end up getting the following output:
Original: http://[2a04:4e42:e00::347%25eth0]/
Parsed: http://[2a04:4e42:e00::347%25eth0]/
Copy: http://[2a04:4e42:e00::347]/
curl version used: 8.2.1-1 x86_64 (Arch Linux)
Thanks,
Rutger
#include <curl/curl.h>
int main(int argc, char *argv[]) {
// Example URL taken from:
// https://everything.curl.dev/libcurl/url/get-part
const char *input_url = "http://[2a04:4e42:e00::347%25eth0]/";
CURLU *h = curl_url();
CURLUcode rc = curl_url_set(h, CURLUPART_URL, input_url, 0);
if (rc) {
printf("Error parsing URL: %s\n", curl_url_strerror(rc));
return 1;
}
CURLU *copy = curl_url_dup(h);
char *h_str, *copy_str;
rc = curl_url_get(h, CURLUPART_URL, &h_str, 0);
if (rc) {
printf("Error printing parsed URL as string: %s\n",
curl_url_strerror(rc));
return 1;
}
rc = curl_url_get(copy, CURLUPART_URL, ©_str, 0);
if (rc) {
printf("Error printing parsed URL as string: %s\n",
curl_url_strerror(rc));
return 1;
}
printf("Original: %s\nParsed: %s\nCopy: %s\n",
input_url, h_str, copy_str);
curl_free(copy_str);
curl_free(h_str);
curl_url_cleanup(copy);
curl_url_cleanup(h);
}
--
Unsubscribe: https://lists.haxx.se/mailman/listinfo/curl-library
Etiquette: https://curl.se/mail/etiquette.html