summaryrefslogtreecommitdiff
path: root/alot/account.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-09-06 14:10:35 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-09-06 14:28:23 -0700
commite1b17942b0ec6fbd351df4c807debd4dc141dcdb (patch)
treea3f70118d78999eb99beb9fbc4b18286c31c5a3b /alot/account.py
parent994320a2750bf6a765cc80d6d8e7ee44927ea3f7 (diff)
account: Fix Address comparison to b'' and u''
This uses a try/except because comparing an address to an empty string should be a fairly uncommon event and try/except will be faster than `if '@' not in other` in the case where '@' is in other. This stops alot from crashing if there is no 'From' header in the email. Outlook generates drafts without a 'From' header. Fixes #1050
Diffstat (limited to 'alot/account.py')
-rw-r--r--alot/account.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/alot/account.py b/alot/account.py
index a224c109..b1223902 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -122,9 +122,15 @@ class Address(object):
The intention is to use functions from the operator module.
"""
if isinstance(other, unicode):
- ouser, odomain = other.split(u'@')
+ try:
+ ouser, odomain = other.split(u'@')
+ except ValueError:
+ ouser, odomain = u'', u''
elif isinstance(other, str):
- ouser, odomain = other.decode('utf-8').split(u'@')
+ try:
+ ouser, odomain = other.decode('utf-8').split(u'@')
+ except ValueError:
+ ouser, odomain = '', ''
else:
ouser = other.username
odomain = other.domainname