Heuristic for invalid source route.

This commit is contained in:
Stuart Gathman
2009-07-04 14:03:09 +00:00
parent aeff1f8ab5
commit 3ed14cc6ab
+4 -1
View File
@@ -101,6 +101,8 @@ def parse_addr(t):
['foo'] ['foo']
>>> parse_addr('@mx.example.com:user@example.com') >>> parse_addr('@mx.example.com:user@example.com')
['user', 'example.com'] ['user', 'example.com']
>>> parse_addr('@user@example.com')
['@user', 'example.com']
""" """
if t.startswith('<') and t.endswith('>'): t = t[1:-1] if t.startswith('<') and t.endswith('>'): t = t[1:-1]
if t.startswith('"'): if t.startswith('"'):
@@ -108,7 +110,8 @@ def parse_addr(t):
pos = t.find('"@') pos = t.find('"@')
if pos > 0: return [t[1:pos],t[pos+2:]] if pos > 0: return [t[1:pos],t[pos+2:]]
if t.startswith('@'): if t.startswith('@'):
t = t.split(':',1)[1] try: t = t.split(':',1)[1]
except IndexError: pass
return t.rsplit('@',1) return t.rsplit('@',1)
## Decode headers gratuitously encoded to hide the content. ## Decode headers gratuitously encoded to hide the content.