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.
Re: Feature Request: Add command line option to url-encode URL?
- Contemporary messages sorted: [ by date ] [ by thread ] [ by subject ] [ by author ] [ by messages with attachments ]
From: Daniel Stenberg via curl-users <curl-users_at_lists.haxx.se>
Date: Mon, 4 Apr 2022 14:29:20 +0200 (CEST)
On Mon, 4 Apr 2022, Cristian Morales Vega via curl-users wrote:
> While library users have https://curl.se/libcurl/c/curl_easy_escape.html,
> AFAICT command line users need to find their own way to URL-encode if they
> want to do something as basic as download a file over HTTP which happens to
> contain a space.
>
> The only related thing I have seen in the man page is "curl will do
> its best to use what you pass to it as a URL. It is not trying to
> validate it as a syntactically correct URL by any means but is instead
> very liberal with what it accepts."
>
> There is anything stopping curl from having a --encode-given-url option?
This is not as easy as it may sound at first.
The original problem here is of course that curl works on URLs. A URL cannot
contain a space so when you provide something to curl that contains a space,
we know it isn't a URL.
When you don't pass a URL to curl, it is rather a sequence of letters in an
unspecified way. What letters in this input string are already encoded and
which are not?
Examples:
If you URL encode a slash, should it become %2f in the output or is there
anything that tells us that slashes are excluded? What about colons? Or
_at_-signs.
A space cannot be part of a URL so we could URL encode spaces to %20. Then
what about spaces in the query part of the URL, should they be encoded as %20
there or as '+' ?
It's a slippery slope.
Date: Mon, 4 Apr 2022 14:29:20 +0200 (CEST)
On Mon, 4 Apr 2022, Cristian Morales Vega via curl-users wrote:
> While library users have https://curl.se/libcurl/c/curl_easy_escape.html,
> AFAICT command line users need to find their own way to URL-encode if they
> want to do something as basic as download a file over HTTP which happens to
> contain a space.
>
> The only related thing I have seen in the man page is "curl will do
> its best to use what you pass to it as a URL. It is not trying to
> validate it as a syntactically correct URL by any means but is instead
> very liberal with what it accepts."
>
> There is anything stopping curl from having a --encode-given-url option?
This is not as easy as it may sound at first.
The original problem here is of course that curl works on URLs. A URL cannot
contain a space so when you provide something to curl that contains a space,
we know it isn't a URL.
When you don't pass a URL to curl, it is rather a sequence of letters in an
unspecified way. What letters in this input string are already encoded and
which are not?
Examples:
If you URL encode a slash, should it become %2f in the output or is there
anything that tells us that slashes are excluded? What about colons? Or
_at_-signs.
A space cannot be part of a URL so we could URL encode spaces to %20. Then
what about spaces in the query part of the URL, should they be encoded as %20
there or as '+' ?
It's a slippery slope.
-- / daniel.haxx.se | Commercial curl support up to 24x7 is available! | Private help, bug fixes, support, ports, new features | https://curl.se/support.html -- Unsubscribe: https://lists.haxx.se/listinfo/curl-users Etiquette: https://curl.haxx.se/mail/etiquette.htmlReceived on 2022-04-04