cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: IMAP and Usernames

From: Michael Wood <esiotrot_at_gmail.com>
Date: Sat, 24 Mar 2012 23:33:02 +0200

On 24 March 2012 20:45, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Sat, 24 Mar 2012, Steve Holme wrote:
>
>> Whilst in IMAP4 the equivalent needs to be:
>>
>> B LOGIN "Steve Holme" <password>
>>
>> When running curl or even my own application I can cope with this by
>> passing
>> in a string that simply contains the quote marks.
>>
>> However, should libcurl detect this and escape the username itself or is
>> it
>> outside its responsibility?
>
>
> I think libcurl should detect and escape, so that the same rules apply to
> user names for libcurl's API independent of protocol.
>
> But your example made me curious. Is there other letters besides space
> (ascii 32) that need quoting? What if you want to use the actuable quote
> letter (") in a user name?

If I'm reading section 9 of RFC3501 correctly, double quotes and
backslashes should be escaped using backslashes, but it's more
complicated than just that.

Roughly:

* The userid argument is an "astring", which is one or more ATOM-CHARs
or a "string".

* A "string" is a "quoted" or a "literal".

* A "quoted" is basically a double quoted string of characters with
any double quotes or backslashes escaped using backslashes.

* A "literal" requires a dialogue with the server. The client sends
{N}CRLF and waits for the server to ask for the "continuation" of the
command. The client then sends N 8-bit characters to the server.

So in something like:

tag LOGIN fred password

"fred" would be an atom.

If you have a space in the username, you'll need to use a string
instead of an atom. Of course the easiest would be a "quoted". If
you have arbitrary 8-bit characters in your username, it seems you'll
need to use a "literal".

The password is also an "astring", so the same rules apply.

See also section 4 (Data Formats).

At least that's my understanding from a brief look at the RFC.

-- 
Michael Wood <esiotrot_at_gmail.com>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-24