cURL / Mailing Lists / curl-library / Single Mail


Re: IMAP and Usernames

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

On 24 March 2012 20:45, Daniel Stenberg <> 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.


* 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 <>
List admin:
Received on 2012-03-24