Re: [Exim] Denying localparts containing backslashes

Top Page
Delete this message
Reply to this message
Author: Philip Hazel
Date:  
To: Hans-Peter Zahno
CC: exim-users
Subject: Re: [Exim] Denying localparts containing backslashes
On Wed, 21 May 2003, Hans-Peter Zahno wrote:

> I'm having troubles with addresses with a leading backslash, like
> <\xyz@???>. Exim seems to ignore the backslash and correctly routing the
> message to our Exchange-Server.


In email addresses, backslash is an escape character. It enables one to
construct local parts that contain "special characters" that are not
normally allowed. For example: "abc\"def"@???. However, from my
reading of the current RFCs, it is permitted only inside a quoted local
part.

Backslash is a special character in address syntax. An address such as
\xyz@??? is therefore syntactically illegal according to the latest
RFCs. Why does Exim accept it then? Answer: because the syntax has been
tightened up. In RFC 821, the original SMTP RFC, we find

            <local-part> ::= <dot-string> | <quoted-string>
            <dot-string> ::= <string> | <string> "." <dot-string>
            <string> ::= <char> | <char> <string>
            <char> ::= <c> | "\" <x>


which allows backslashed characters in unquoted local parts. Thus,

MAIL FROM:<\xyz@???>

is legal according to my reading of RFC 821. I don't think this form of
address is legal according to RFC 822, that is, it wasn't ever
(strictly) allowed in message header lines. This is the anomaly that has
been tightened up in the latest RFCs, where backslash appears to be
permitted only inside quoted strings. Please correct me if I'm wrong!
Interpreting this stuff is not straightforward...

However, when a backslash does appear (legally) in a local part, the
interpretation of such a construction is just to take the escaped
character as a literal part of the local part. That is why Exim treats
\xyz@??? as local_part=xyz and domain=unifr.ch.

If you really want to have a local part whose characters are \xyz, the
correct encoding of the address is "\\xyz"@???.

--
Philip Hazel            University of Cambridge Computing Service,
ph10@???      Cambridge, England. Phone: +44 1223 334714.
Get the Exim 4 book:    http://www.uit.co.uk/exim-book