]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Don't blow up when a server returns an all-digits folder name with quoting (#107)
authorMenno Smits <menno@freshfoo.com>
Tue, 13 Mar 2012 13:39:43 +0000 (13:39 +0000)
committerMenno Smits <menno@freshfoo.com>
Tue, 13 Mar 2012 13:39:43 +0000 (13:39 +0000)
NEWS
THANKS
imapclient/imapclient.py
imapclient/test/test_IMAPClient.py

diff --git a/NEWS b/NEWS
index 3b3482116889f339db1180df6998e1ce3fc72974..e4b6e785c7f20b852a36cfd7379654b6dd280b66 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,7 +6,12 @@
 
 * New methods for interacting the Gmail's label API: get_gmail_labels,
   add_gmail_labels, set_gmail_labels, remove_gmail_labels. Thanks to
-  Brian Neal for the patch.
+  Brian Neal for the patches.
+
+Minor Features
+--------------
+* Don't traceback when an IMAP server returns a all-digit folder name
+  without quotes. Thanks to Rhett Garber for the bug report. (#107)
 
 =======
  0.8.1
diff --git a/THANKS b/THANKS
index 89f5298117fd356a33fd5aaa0361e4a15665187c..0e99097de9065d7ffb82e3bbc5664b20156aed94 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -40,6 +40,7 @@ Neil Martinsen-Burrell
 Mark Eichin (eichin _AT_ thok.org)
 Fergal Daly (fergal _AT_ esatclear.ie)
 Bob Yexley (bob _AT_ yexley.net)
+Rhett Garber
 
 
 The project was partially developed while the author was working at NetBox Blue
index f17d50358a3f27a319c68eab5e11e1b653af3966..d2a678810fc9e7f8437ccf1b2e13600c78091ddb 100644 (file)
@@ -872,6 +872,11 @@ class IMAPClient(object):
             ])
 
     def _decode_folder_name(self, name):
+        if isinstance(name, int):
+            # Some IMAP implementations return integer folder names
+            # with quotes. These get parsed to ints so convert them
+            # back to strings.
+            return str(name)
         if self.folder_encode:
             return imap_utf7.decode(name)
         return name
index a189ae5433f0cca57a98f36fcf01b1b83fa6a3eb..17c0692c4e7ddfd82fd2631b4ff60199255ac568 100644 (file)
@@ -71,6 +71,10 @@ class TestListFolders(IMAPClientTest):
                                    (['\\HasNoChildren'], '/', 'B'),
                                    (['\\HasNoChildren'], '/', 'C')])
 
+    def test_unquoted_numeric_folder_name(self):
+        # Some IMAP implementations do this
+        folders = self.client._proc_folder_list(['(\\HasNoChildren) "/" 123'])
+        self.assertEqual(folders, [(['\\HasNoChildren'], '/', '123')])
 
     def test_mixed(self):
         folders = self.client._proc_folder_list(['(\\HasNoChildren) "/" Alpha',