]> khamidou — GitHub mirrors - imapclient.git/commitdiff
Fixed folder name processing for unqouted numeric names that overflow maxint and...
authorPaweł Gorzelany <pawel.gorzelany@gmail.com>
Mon, 3 Aug 2015 16:16:45 +0000 (18:16 +0200)
committerPaweł Gorzelany <pawel.gorzelany@gmail.com>
Mon, 3 Aug 2015 16:16:45 +0000 (18:16 +0200)
imapclient/imapclient.py
imapclient/test/test_imapclient.py

index c3292972c71f42730b6a69fb72388a0fb4dbb7ae..e6e8723b6be854705708b190bc331518ec8bd064 100644 (file)
@@ -412,7 +412,7 @@ class IMAPClient(object):
             flags, delim, name = parsed[:3]
             parsed = parsed[3:]
 
-            if isinstance(name, int):
+            if isinstance(name, (int, long)):
                 # Some IMAP implementations return integer folder names
                 # with quotes. These get parsed to ints so convert them
                 # back to strings.
index 98642c0125df4b6beeabb9604e60300a6a84b675..9da692ed223e7a244ddfb1cc116a0a0a694f4556 100644 (file)
@@ -103,6 +103,12 @@ class TestListFolders(IMAPClientTest):
         folders = self.client._proc_folder_list([b'(\\HasNoChildren) "/" 123'])
         self.assertEqual(folders, [((b'\\HasNoChildren',), b'/', '123')])
 
+    def test_unqouted_numeric_folder_name_parsed_as_long(self):
+        # big enough numeric values might get parsed as longs
+        folder_name = str(sys.maxint + 1)
+        folders = self.client._proc_folder_list([b'(\\HasNoChildren) "/" %s' % folder_name])
+        self.assertEqual(folders, [((b'\\HasNoChildren', ), b'/', folder_name)])
+
     def test_mixed(self):
         folders = self.client._proc_folder_list([b'(\\HasNoChildren) "/" Alpha',
                                                  b'(\\HasNoChildren) "/" "Foo Bar"',