curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Escaping URL for CURLOPT_URL

From: Andreas Falkenhahn via curl-library <curl-library_at_lists.haxx.se>
Date: Wed, 20 Apr 2022 16:41:22 +0200

Hi,

is there any convenient way of escaping a URL so that it can be passed to CURLOPT_URL?

I've seen that there is a curl_easy_escape() function but it will escape the whole URL, i.e. including the :// used to separate scheme and host. Escaping this URL

   http://jpv.amigaaa.com/test/url test/test%file.txt

using curl_easy_escape() will result in

   http%3A%2F%2Fjpv.amigaaa.com%2Ftest%2Furl%20test%2Ftest%25file.txt

But I can't pass that URL to CURLOPT_URL because something seems to confuse CURLOPT_URL here, maybe the fact that the :// is escaped into %3A%2F%2F or the fact that the path separating slashes are escaped into %2F. I can get it to work by manually tweaking the URL like this:

   http://jpv.amigaaa.com/test/url%20test/test%25file.txt

So I was wondering: Is there any way to escape a URL for passing it to CURLOPT_URL? Or how am I supposed to deal with this?

-- 
Best regards,
 Andreas Falkenhahn                          mailto:andreas_at_falkenhahn.com
-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-04-20