Allow folder names with atom specials
This patch allows using folders with atom-specials like "(", ")", spaces,... We need quotes the folder name if it includes this special characters. Closes #4
This commit is contained in:
parent
011cfbc670
commit
01c621d86c
@ -91,7 +91,7 @@ class IMAPFolder(BaseFolder):
|
||||
name = self.getfullname()
|
||||
if self.repository.account.utf_8_support:
|
||||
name = imaputil.utf8_IMAP(name)
|
||||
return name
|
||||
return imaputil.foldername_to_imapname(name)
|
||||
|
||||
# Interface from BaseFolder
|
||||
def suggeststhreads(self):
|
||||
|
@ -435,3 +435,23 @@ def imap4_utf_7(name):
|
||||
|
||||
|
||||
codecs.register(imap4_utf_7)
|
||||
|
||||
|
||||
def foldername_to_imapname(folder_name):
|
||||
"""
|
||||
This function returns the folder_name ready to send to the
|
||||
IMAP server. It tests if the folder_name has special characters
|
||||
Then, quote it.
|
||||
Args:
|
||||
folder_name: Folder's name
|
||||
|
||||
Returns: The folder_name quoted if needed
|
||||
|
||||
"""
|
||||
# If name includes some of these characters, quote it
|
||||
atom_specials = [' ', '/', '(', ')', '{', '}']
|
||||
|
||||
if any((c in atom_specials) for c in folder_name):
|
||||
folder_name = '"' + folder_name + '"'
|
||||
|
||||
return folder_name
|
Loading…
Reference in New Issue
Block a user