diff --git a/imap_tools/folder.py b/imap_tools/folder.py index 2a5bfe8..8bf075b 100644 --- a/imap_tools/folder.py +++ b/imap_tools/folder.py @@ -107,13 +107,21 @@ def list(self, folder: str or bytes = '', search_args: str = '*', subscribed_onl typ, data = self.mailbox.box._simple_command( command, self._encode_folder(folder), self._encode_folder(search_args)) typ, data = self.mailbox.box._untagged_response(typ, data, command) - result = list() + result = [] for folder_item in data: if not folder_item: continue - folder_match = re.search(folder_item_re, imap_utf7.decode(folder_item)) - folder_dict = folder_match.groupdict() - if folder_dict['name'].startswith('"') and folder_dict['name'].endswith('"'): - folder_dict['name'] = folder_dict['name'][1:-1] + if type(folder_item) is bytes: + folder_match = re.search(folder_item_re, imap_utf7.decode(folder_item)) + folder_dict = folder_match.groupdict() + if folder_dict['name'].startswith('"') and folder_dict['name'].endswith('"'): + folder_dict['name'] = folder_dict['name'][1:-1] + elif type(folder_item) is tuple: + # when name has " or \ chars + folder_match = re.search(folder_item_re, imap_utf7.decode(folder_item[0])) + folder_dict = folder_match.groupdict() + folder_dict['name'] = imap_utf7.decode(folder_item[1]) + else: + continue result.append(folder_dict) return result diff --git a/release_notes.rst b/release_notes.rst index 46eb120..564af22 100644 --- a/release_notes.rst +++ b/release_notes.rst @@ -1,3 +1,7 @@ +0.14.2 +====== +* Fixed bug in folder.MailBoxFolderManager.exists/list on folder names with " and \ chars + 0.14.1 ====== * Fixed bug on folders names with space in folder.MailBoxFolderManager.exists/list diff --git a/setup.py b/setup.py index b8aa49e..9b85e1b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name='imap_tools', - version='0.14.1', + version='0.14.2', packages=setuptools.find_packages(), url='https://github.com/ikvk/imap_tools', license='Apache-2.0', diff --git a/todo.txt b/todo.txt index d6225d9..364fdd0 100644 --- a/todo.txt +++ b/todo.txt @@ -3,5 +3,3 @@ try to imitate long poll by NOOP check https://docs.python.org/release/3.8.1/library/email.utils.html check possibility to implement SOCKS without/with dependencies - -folder.list fails on names with \\ "" chars