summaryrefslogtreecommitdiff
path: root/alot/account.py
diff options
context:
space:
mode:
authorPatrick Totzke <patricktotzke@gmail.com>2012-03-10 20:40:21 +0000
committerPatrick Totzke <patricktotzke@gmail.com>2012-03-10 20:40:21 +0000
commit15b01d8c3fd7150f3b271ca98ebbc714977d0344 (patch)
tree744d1f0446175e16f353c0a57d873acbe1a840d2 /alot/account.py
parent208e8f4bf94afaf2b5cbd2681f9c2b61ce43c103 (diff)
safer globbing in Account.store_mail
we use glob to find the path to a newly stored message file. This makes us use glob.glob1 instead of glob.glob to make sure the mailbox path is taken as is - and not interpreted as as regular expression, e.g. if it contains square brackets. This further ensures we don't access a possibly empty list out of index closes #401
Diffstat (limited to 'alot/account.py')
-rw-r--r--alot/account.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/alot/account.py b/alot/account.py
index ab6c9af7..88d2ce10 100644
--- a/alot/account.py
+++ b/alot/account.py
@@ -129,7 +129,10 @@ class Account(object):
if isinstance(mbx, mailbox.Maildir):
# this is a dirty hack to get the path to the newly added file
# I wish the mailbox module were more helpful...
- path = glob.glob(os.path.join(mbx._path, '*', message_id + '*'))[0]
+ plist = glob.glob1(os.path.join(mbx._path, 'new'), message_id + '*')
+ if plist:
+ path = os.path.join(mbx._path, 'new', plist[0])
+ logging.debug('path of saved msg: %s' % path)
return path
def store_sent_mail(self, mail):