]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Handle empty strings and None when processing list responses
authorMenno Smits <menno@freshfoo.com>
Tue, 29 Dec 2009 22:03:43 +0000 (22:03 +0000)
committerMenno Smits <menno@freshfoo.com>
Tue, 29 Dec 2009 22:03:43 +0000 (22:03 +0000)
imapclient/imapclient.py
imapclient/test/test_IMAPClient.py

index 22c45b1eafccf7c37266900379df511742e9fc5e..8f1724cece1f7e351437fc53dbc72056e6e66b36 100644 (file)
@@ -11,6 +11,7 @@ import datetime
 import imap_utf7
 from fixed_offset import FixedOffset
 
+
 __all__ = ['IMAPClient', 'DELETED', 'SEEN', 'ANSWERED', 'FLAGGED', 'DRAFT',
     'RECENT']
 
@@ -186,7 +187,7 @@ class IMAPClient(object):
             folder_text = None
             if isinstance(line, tuple):
                 folder_text = line[-1]
-            else:
+            elif line:
                 match = self.re_folder.match(line)
                 if match:
                     folder_text = match.group('folder')
index 212daa0da41a62cb5267858c4f6f9abc8d1ea595..81339087c1bfc44762435833f4d54807f1c0bf1d 100644 (file)
@@ -89,6 +89,11 @@ class TestListFolders(IMAPClientTest):
                                                  ])
         self.assert_(folders == ['Test "Folder"', 'Left\"Right', r'Left\Right'], 'got %r' % folders)
 
+    def test_blanks(self):
+        folders = self.client._proc_folder_list(['', None, 
+                                                 r'(\\HasNoChildren) "/" "last"',
+                                                ])
+        self.assert_(folders == ['last'], 'got %r' % folders)
 
 
 class TestAppend(IMAPClientTest):