[Imap-protocol] literal usage
Mark Crispin
mrc at CAC.Washington.EDU
Tue Mar 20 09:04:05 PDT 2007
On Tue, 20 Mar 2007, Alain Spineux wrote:
> When does a _server_ OR a _client_ use a literals ?
An implementation will use literals if it must; that is, the string can
not be represented as atom or quoted.
An implementation is likely to do so when it is uncomfortable with the
contents; for example, \ was an ordinary character quoted strings in IMAP2
and thus implementations that seek to be IMAP2 compatible will avoid using
quoted strings that have \ quoting. Another reason for discomfort is if
the string is long; parsing for the trailing quote is more work than
handling the literal.
Or, it can use literals just because it wants to.
> What is the correct usage when mixing literal and string,
> does I need to insert a space between the end of a literal ?
This is defined by the formal syntax. It is incorrect to ask your
question, because that assumes a single answer. The formal syntax defines
what delimiter appears after the literal.
As a general rule, one (and only one) space separates tokens in IMAP.
However, that is not associated with the token, but rather the syntax. If
the token is the last item of a list, there would be a close parenthesis
instead of a space after it.
> For example for a setacl mailbox username lrswipcda, where I mix strings
> ands literals
>
> (Here .. means CRLF)
>
> C: 000001 SETACL "mailbox" {8}
> S: wait for server "continuation response"
> C: username..<DO I NEED TO INSERT A SPACE HERE>lrswipcda..
That is defined by the syntax of SETACL. In that case, yes there is a
SPACE and not a CRLF.
Again, please use the formal syntax and not code rules into your handling
of literals. After a literal is either a delimiter or end of string; that
is all that the literal handler should know. A higher level rule that
handles the syntax of the command will deal with what the delimiter is.
-- Mark --
http://panda.com/mrc
Democracy is two wolves and a sheep deciding what to eat for lunch.
Liberty is a well-armed sheep contesting the vote.
More information about the Imap-protocol
mailing list