cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: How to encode names for FTP ?

From: Silex <silex0r_at_gmail.com>
Date: Tue, 4 Apr 2006 16:26:40 +0200

ok so if I understood correctly, if I have a string like :

ftp://user:pass@www.server.com/path/file.txt

I must curl_escape :

-user
-pass
-www.server.com
-path
-file.txt

Did I get it right ? I'm somehow still unsure that I must encode things like
www.server.com because of the dots in it...

Thank you in advance
Philippe

On 4/3/06, Daniel Stenberg <daniel_at_haxx.se> wrote:
>
> On Fri, 31 Mar 2006, Silex wrote:
>
> > Basically, I'm uploading a file and its name may contains spaces or
> weird
> > characters like %.
>
> Then upload to a URL and encode the URL properly - URL encoded is usually
> the
> term.
>
> > As far as I understood, whenever I set CURLOPT_URL, I must replace the %
> > contained in it with %25, is that right ?
>
> Yes, all reservered characters must be replaced with %HH where HH is the
> hexadecimal representation.
>
> > I must not try to add quotes or whatever if there's a space in the file
> > name, and I must only treat the % char.
>
> A space is %20 in a URL.
>
> > It seems that I should *not* use curl_escape for that because otherwise
> > things like / etc get encoded as well.
>
> When you create a URL you need to escape each individual part of the URL
> and
> then append them all and create the URL with the proper "part" separators.
> Like for directory names you need to escape the names but then join them
> with
> a slash separating them.
>
> > Now, after uploading the file, I use a curl_slist along with
> > CURLOPT_POSTQUOTE to do a chmod on the file. Here too, should I replace
> the
> > % the same way for the filename ?
>
> No. The *QUOTE options are plain strings you send to the FTP server
> unmodified
> and untouch by libcurl. You need to send those strings to the server in a
> format that the server expects and wants them to be. That is actually a
> much
> less defined area. RFC959 is not at all very clear on how to encode
> "weird"
> characters. At least I didn't find it the last time I checked.
>
> --
> Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
>
Received on 2006-04-04