Author sdossey
Date 2004-10-19.19:51:33
SpamBayes Score
Marked as misclassified

THe following email address is legal according to RFC:

<"\"quoted string\" somebody"">

I've got a python mail handling back end server that
handles mail coming in from Postfix.  Postfix properly
accepts mail of this type, but when it goes to relay
this through my Python server it fails.

The problem is inside inside "quoteaddr". 
Here's a source code snippet:

def quoteaddr(addr)
    """Quote a subset of the email addresses defined by
RFC 821.

    Should be able to handle anything rfc822.parseaddr
can handle.
    m = (None, None)
    except AttributeError:
    if m == (None, None): # Indicates parse failure or
        #something weird here.. punt -ddm
        return "<%s>" % addr

Basically quoteaddr ends up wrapping whatever parseaddr
returns to it in brackets and sending that  out on the
wire for the RCPT TO command.

however, if I call rfc822.parseaddr it does bizarre
things to email addresses. 

For instance the following calls all yield the same
thing (some not surprisingly):

rfc822.parseaddr('""test" test"')
rfc822.parseaddr('"\"test\" test"')
rfc822.parseaddr('"\\"test\\" test"')
rfc822.parseaddr('"\\\"test\\\" test"@test/com')

the above all yield:
('', '""test" test"')

rfc822.parseaddr('"\\\\"test\\\\" test"@test/com')
yields the VERY surprising result:
('', '"\\"test\\\\" test"')

I submitted this as a new bug report even though there
are two similar bugs regarding parseAddr because it is
a slightly separate issue.

-Scott Dossey <seveirein /at/> 
Date User Action Args
2007-08-23 14:26:55adminlinkissue1050268 messages
2007-08-23 14:26:55admincreate