summaryrefslogtreecommitdiff
path: root/alot
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2017-08-08 12:56:28 -0700
committerDylan Baker <dylan@pnwbakers.com>2017-08-28 16:53:04 -0700
commit362268d9a506c1d87f197bccef6fed0dcb83d629 (patch)
treecf0f48c8c93ff908cfbe37aece817af7b716ca81 /alot
parent593539bd091dfc53af62180b6a5559487213f953 (diff)
Use new Address class
This just wries the new Address class into alot for use, and fixes up a few places where such fixups are needed. Fixes #1107
Diffstat (limited to 'alot')
-rw-r--r--alot/account.py7
-rw-r--r--alot/commands/thread.py6
-rw-r--r--alot/defaults/alot.rc.spec8
3 files changed, 16 insertions, 5 deletions
diff --git a/alot/account.py b/alot/account.py
index 01a536d0..e561f0c9 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -201,7 +201,7 @@ class Account(object):
signature_filename=None, signature_as_attachment=False,
sent_box=None, sent_tags=None, draft_box=None,
draft_tags=None, abook=None, sign_by_default=False,
- encrypt_by_default=u"none",
+ encrypt_by_default=u"none", case_sensitive_username=False,
**_):
sent_tags = sent_tags or []
if 'sent' not in sent_tags:
@@ -210,8 +210,9 @@ class Account(object):
if 'draft' not in draft_tags:
draft_tags.append('draft')
- self.address = address
- self.aliases = aliases or []
+ self.address = Address.from_string(address, case_sensitive=case_sensitive_username)
+ self.aliases = [Address.from_string(a, case_sensitive=case_sensitive_username)
+ for a in (aliases or [])]
self.alias_regexp = alias_regexp
self.realname = realname
self.gpg_key = gpg_key
diff --git a/alot/commands/thread.py b/alot/commands/thread.py
index 02017ae9..437a9bd0 100644
--- a/alot/commands/thread.py
+++ b/alot/commands/thread.py
@@ -71,11 +71,13 @@ def determine_sender(mail, action='reply'):
# pick the most important account that has an address in candidates
# and use that accounts realname and the address found here
for account in my_accounts:
- acc_addresses = [re.escape(a) for a in account.get_addresses()]
+ acc_addresses = [re.escape(unicode(a)) for a in account.get_addresses()]
if account.alias_regexp is not None:
acc_addresses.append(account.alias_regexp)
for alias in acc_addresses:
- regex = re.compile('^' + alias + '$', flags=re.IGNORECASE)
+ regex = re.compile(
+ u'^' + unicode(alias) + u'$',
+ flags=re.IGNORECASE if not account.address.case_sensitive else 0)
for seen_name, seen_address in candidate_addresses:
if regex.match(seen_address):
logging.debug("match!: '%s' '%s'", seen_address, alias)
diff --git a/alot/defaults/alot.rc.spec b/alot/defaults/alot.rc.spec
index 97de329d..eeae4348 100644
--- a/alot/defaults/alot.rc.spec
+++ b/alot/defaults/alot.rc.spec
@@ -355,6 +355,14 @@ thread_focus_linewise = boolean(default=True)
# use your default key.
gpg_key = gpg_key_hint(default=None)
+ # Whether the server treats the address as case-senstive or
+ # case-insensitve (True for the former, False for the latter)
+ #
+ # .. note:: The vast majority (if not all) SMTP servers in modern use
+ # treat usernames as case insenstive, you should only set
+ # this if you know that you need it.
+ case_sensitive_username = boolean(default=False)
+
# address book for this account
[[[abook]]]
# type identifier for address book