msg27314 - (view) |
Author: Mark Sapiro (msapiro) *  |
Date: 2006-01-18 22:19 |
email.Utils.parseaddr('Real Name ((comment)) <addr...@example.com>') returns ('comment <addr...@example.com>', 'Real') Granted the string above is invalid as RFC 2822 does not allow parentheses within comments, but most mail agents seem to at least take the contents of the angle brackets as the address in this case. rfc822.parseaddr() returns the same result in this case. If these functions aren't going to return their respective failure indication in this case, I think they should at least return 'addr...@example.com' as the second item of the returned tuple. Note that parseaddr('Real Name <addr...@example.com> ((comment))') does return ('Real Name', 'addr...@example.com') as 'expected'. |
|
|
msg27315 - (view) |
Author: Mark Sapiro (msapiro) *  |
Date: 2006-04-21 17:01 |
Logged In: YES user_id=1123998 It looks like this is addressed by patch 1464708 http://sourceforge.net/tracker/index.php?func=detail&aid=1464708&group_id=5470&atid=305470 |
|
|
msg83892 - (view) |
Author: Daniel Diniz (ajaksu2) *  |
Date: 2009-03-20 23:51 |
Fixed in trunk, so issue 1464708 was probably forward ported. |
|
|
msg110548 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-07-17 11:38 |
I wonder if this bug should be reopened. This behavior does not seem right to me: parsing 'merwok' expected ('merwok', '') got ('', 'merwok') parsing 'merwok wok@rusty' expected ('', 'wok@rusty') got ('', 'merwokwok@rusty') (Generated with a twenty-line script just doing a loop and prints, not attached because boring.) Are my expectations wrong? I don’t know if a string like “merwok” in my first example is a legal address in the relevant RFCs, nor do I know if the folding done in the second example is okay. For background, the thing I’m trying to achieve is to take a string and parse it into name and email address, and print a warning if there is no email. It’d be nice if I could always test for “not parseaddr(s)[1]”, or pass an argument to the function to get an exception. Maybe I’ll have to restrict my format and do my own parsing with str.[r]partition. |
|
|
msg110556 - (view) |
Author: Mark Sapiro (msapiro) *  |
Date: 2010-07-17 14:07 |
> parsing 'merwok' > expected ('merwok', '') > got ('', 'merwok') I think ('', 'merwok') is the correct result. I think most if not all MUAs/MTAs will interpret an address without an '@', albeit invalid, as a local-part in the local domain, thus parsing 'merwok' as the address 'merwok' with no real name is probably the right thing to do with this input. The alternative would be to return ('', '') indicating failure. > parsing 'merwok wok@rusty' > expected ('', 'wok@rusty') > got ('', 'merwokwok@rusty') Here, I think failure is a more appropriate return. In any case, I think this is a new bug deserving of a new report. It is not really relevant to this issue which has to do with nested parentheses. |
|
|
msg110558 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-07-17 14:25 |
Thank you for the reply. The problem is that parseaddr is designed to not fail IIUC, that’s why it may return empty strings. Client code has to check for these values instead of catching an exception—a mere style issue, weren’t it for the second bug. So I’m going to report that separately, and restrict the format in my project so that my code can just use string methods. I think I won’t open a feature request for a parameter to get exceptions, since parseaddr is designed not to. |
|
|
msg110562 - (view) |
Author: Éric Araujo (eric.araujo) *  |
Date: 2010-07-17 14:36 |
Copied my inquiry and part of your reply in #9286. |
|
|