cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl question - passwords with '%'...

From: Philip Butler <butler_at_globeserver.com>
Date: Mon, 5 May 2003 10:35:51 -0400

Daniel,

Thanks for the input - when I was playing with curl_encode, I was
trying to encode the entire URL - not the username/password separately.
  I'll give this a try.

Again, many thanks.

Phil

On Monday, May 5, 2003, at 10:24 AM, Daniel Stenberg wrote:

> On Mon, 5 May 2003, Philip Butler wrote:
>
>> I am using libcurl to do some FTP'ing... The one problem that I am
>> running into is that I need to enter a password with a '%' - for
>> example, a site URL may be
>> ftp://username:pass%word@ftp.something.com/path/path/file.ext. My app
>> works if the password does not have an embedded '%'.
>>
>> I have seen the docs on curl_escape and curl_unescape - not sure if
>> these would help me or not.
>
> You need to URL-encode the password (and the user name too in case you
> want
> to support non-URL-supported letters in the user name). When that is
> made, a
> '%' letter appears as '%25'.
>
> You can use curl_escape() to produce an URL-formatted string out of a
> "normal" string. Something like this:
>
> char *encoded_password = curl_escape(password, 0);
> char *encoded_username = curl_escape(username, 0);
>
> sprintf(url, "ftp://%s@%s:ftp.something.com/path/path/file.ext",
> encoded_username, encoded_password);
>
> curl_free(encoded_password);
> curl_free(encoded_username);
>
> --
> Daniel Stenberg -- curl, cURL, Curl, CURL. Groks URLs.
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf

-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
Received on 2003-05-05