From 1ef506655cd923e5a8f5db0ad81b73cf79c29f9b Mon Sep 17 00:00:00 2001 From: Eygene Ryabinkin Date: Tue, 27 Aug 2013 15:57:55 +0400 Subject: [PATCH] Catch two instances of untested regexp matches They could possibly lead to the problems mentioned in https://github.com/OfflineIMAP/offlineimap/issues/6 though there are no sound evidences for this. Signed-off-by: Eygene Ryabinkin --- offlineimap/folder/Maildir.py | 2 ++ offlineimap/imaputil.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/offlineimap/folder/Maildir.py b/offlineimap/folder/Maildir.py index 23f48b4..3d6fd62 100644 --- a/offlineimap/folder/Maildir.py +++ b/offlineimap/folder/Maildir.py @@ -104,6 +104,8 @@ class MaildirFolder(BaseFolder): oldest_time_utc -= oldest_time_today_seconds timestampmatch = re_timestampmatch.search(messagename) + if not timestampmatch: + return True timestampstr = timestampmatch.group() timestamplong = long(timestampstr) if(timestamplong < oldest_time_utc): diff --git a/offlineimap/imaputil.py b/offlineimap/imaputil.py index fe69b7a..231fb14 100644 --- a/offlineimap/imaputil.py +++ b/offlineimap/imaputil.py @@ -145,6 +145,10 @@ def imapsplit(imapstring): elif workstr[0] == '"': # quoted fragments '"...\"..."' m = quotere.match(workstr) + if not m: + raise ValueError ("failed to parse " + "quoted component %s " % str(workstr) + \ + "while working with %s" % str(imapstring)) retval.append(m.group('quote')) workstr = m.group('rest') else: