From: Menno Smits Date: Tue, 13 Mar 2012 13:39:43 +0000 (+0000) Subject: Don't blow up when a server returns an all-digits folder name with quoting (#107) X-Git-Tag: 0.9~25^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=c0f7487eebd342ac108a8f70dbd30289bdfc89d9;p=imapclient.git Don't blow up when a server returns an all-digits folder name with quoting (#107) --- diff --git a/NEWS b/NEWS index 3b34821..e4b6e78 100644 --- 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 89f5298..0e99097 100644 --- 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 diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py index f17d503..d2a6788 100644 --- a/imapclient/imapclient.py +++ b/imapclient/imapclient.py @@ -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 diff --git a/imapclient/test/test_IMAPClient.py b/imapclient/test/test_IMAPClient.py index a189ae5..17c0692 100644 --- a/imapclient/test/test_IMAPClient.py +++ b/imapclient/test/test_IMAPClient.py @@ -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',