[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-10 Thread Stuart D Gathman

Changes by Stuart D Gathman:


--
type:  -> behavior

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-10 Thread Stuart D Gathman

Stuart D Gathman added the comment:

# A quick and very dirty fix for common broken cases, with test cases.

import rfc822

def parseaddr(t):
  """Split email into Fullname and address.

  >>> parseaddr('[EMAIL PROTECTED]')
  ('', '[EMAIL PROTECTED]')
  >>> parseaddr('"Full Name" <[EMAIL PROTECTED]>')
  ('Full Name', '[EMAIL PROTECTED]')
  >>> parseaddr('[EMAIL PROTECTED] <[EMAIL PROTECTED]>')
  ('[EMAIL PROTECTED]', '[EMAIL PROTECTED]')
  >>> parseaddr('"God" <@hop1.org,@hop2.net:[EMAIL PROTECTED]>')
  ('God', '[EMAIL PROTECTED]')
  """
  #return email.Utils.parseaddr(t)
  res = rfc822.parseaddr(t)
  # dirty fix for some broken cases
  if not res[0]:
pos = t.find('<')
if pos > 0 and t[-1] == '>':
  addrspec = t[pos+1:-1]
  pos1 = addrspec.rfind(':')
  if pos1 > 0:
addrspec = addrspec[pos1+1:]
  return rfc822.parseaddr('"%s" <%s>' % (t[:pos].strip(),addrspec))
  if not res[1]:
pos = t.find('<')
if pos > 0 and t[-1] == '>':
  addrspec = t[pos+1:-1]
  pos1 = addrspec.rfind(':')
  if pos1 > 0:
addrspec = addrspec[pos1+1:]
  return rfc822.parseaddr('%s<%s>' % (t[:pos].strip(),addrspec))
  return res

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-10 Thread Stuart D Gathman

Stuart D Gathman added the comment:

Ok, I see the '@' is technically not allowed in an atom.  But it either
needs to throw an invalid syntax exception, or heuristically return
something reasonable.

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-10 Thread Stuart D Gathman

Stuart D Gathman added the comment:

Repeating because previous real life test case was rejected as 'spam':

It also fails to parse:
>>> from email.Utils import parseaddr
>>> parseaddr('[EMAIL PROTECTED] <[EMAIL PROTECTED]>')
('', '[EMAIL PROTECTED]')

Getting the wrong part as the actual email to boot!  Checked 2.4 and 2.5.

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-11 Thread Stuart D Gathman

Stuart D Gathman added the comment:

Test cases so far:
  >>> parseaddr('[EMAIL PROTECTED]')
  ('', '[EMAIL PROTECTED]')
  >>> parseaddr('"Full Name" <[EMAIL PROTECTED]>')
  ('Full Name', '[EMAIL PROTECTED]')
  >>> parseaddr('[EMAIL PROTECTED] <[EMAIL PROTECTED]>')
  ('[EMAIL PROTECTED]', '[EMAIL PROTECTED]')
  >>> parseaddr('[EMAIL PROTECTED] <@hop1.org,@hop2.net:[EMAIL PROTECTED]>')
  ('[EMAIL PROTECTED]', '[EMAIL PROTECTED]')
  >>> parseaddr('Real Name ((comment)) <[EMAIL PROTECTED]>')
  ('Real Name', '[EMAIL PROTECTED]')
  >>> parseaddr('a(WRONG)@b')
  ('', '[EMAIL PROTECTED]')

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1221] email.Utils.parseaddr("a(WRONG)@b")

2008-01-11 Thread Stuart D Gathman

Stuart D Gathman added the comment:

See Issue1025395

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1221>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1221] email.Utils.parseaddr("a(WRONG)@b")

2008-01-11 Thread Stuart D Gathman

Stuart D Gathman added the comment:

see Issue1029395

--
nosy: +sdgathman

__
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1221>
__
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-11 Thread Stuart D Gathman

Stuart D Gathman added the comment:

Same or related issues: Issue1221, Issue1409460

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1025395] email.Utils.parseaddr fails to parse valid addresses

2008-01-11 Thread Stuart D Gathman

Stuart D Gathman added the comment:

tiran: yes, but that is the wrong answer, and that example is already in
the testcase list (with what I believe is the right answer).

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1025395>
_
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com