From 3ed14cc6abbc4702317a8ed428eb1a206000ce48 Mon Sep 17 00:00:00 2001 From: Stuart Gathman <stuart@gathman.org> Date: Sat, 4 Jul 2009 14:03:09 +0000 Subject: [PATCH] Heuristic for invalid source route. --- Milter/utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Milter/utils.py b/Milter/utils.py index 9f077ef..93f8645 100644 --- a/Milter/utils.py +++ b/Milter/utils.py @@ -101,6 +101,8 @@ def parse_addr(t): ['foo'] >>> parse_addr('@mx.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('"'): @@ -108,7 +110,8 @@ def parse_addr(t): pos = t.find('"@') if pos > 0: return [t[1:pos],t[pos+2:]] if t.startswith('@'): - t = t.split(':',1)[1] + try: t = t.split(':',1)[1] + except IndexError: pass return t.rsplit('@',1) ## Decode headers gratuitously encoded to hide the content. -- GitLab