From: Paweł Gorzelany Date: Mon, 3 Aug 2015 16:16:45 +0000 (+0200) Subject: Fixed folder name processing for unqouted numeric names that overflow maxint and... X-Git-Tag: 1.0.0~1^2~47^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=b572d5fff651f54ffb763b2ad37f0bdab2c821ba;p=imapclient.git Fixed folder name processing for unqouted numeric names that overflow maxint and get parsed as longs --- diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index c329297..e6e8723 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -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. diff --git a/imapclient/test/test_imapclient.py b/imapclient/test/test_imapclient.py index 98642c0..9da692e 100644 --- a/imapclient/test/test_imapclient.py +++ b/imapclient/test/test_imapclient.py @@ -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"',