repository: IMAP: correctly check the response while listing remote folders
Github-ref: https://github.com/OfflineIMAP/offlineimap/issues/423 Reported-by: Periklis Tsirakidis <periklis.tsirakidis@mayflower.de> Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
parent
dab5737265
commit
11655cb613
@ -454,17 +454,29 @@ class IMAPRepository(BaseRepository):
|
|||||||
listfunction = imapobj.list
|
listfunction = imapobj.list
|
||||||
if self.getconfboolean('subscribedonly', False):
|
if self.getconfboolean('subscribedonly', False):
|
||||||
listfunction = imapobj.lsub
|
listfunction = imapobj.lsub
|
||||||
|
|
||||||
try:
|
try:
|
||||||
listresult = listfunction(directory=self.imapserver.reference)[1]
|
result, listresult = listfunction(directory=self.imapserver.reference)
|
||||||
|
if result != 'OK':
|
||||||
|
raise OfflineImapError("Could not list the folders for"
|
||||||
|
" repository %s. Server responded: %s"%
|
||||||
|
(self.name, self, str(listresult)),
|
||||||
|
OfflineImapError.ERROR.FOLDER)
|
||||||
finally:
|
finally:
|
||||||
self.imapserver.releaseconnection(imapobj)
|
self.imapserver.releaseconnection(imapobj)
|
||||||
|
|
||||||
for s in listresult:
|
for s in listresult:
|
||||||
if s == None or \
|
if s == None or \
|
||||||
(isinstance(s, str) and s == ''):
|
(isinstance(s, str) and s == ''):
|
||||||
# Bug in imaplib: empty strings in results from
|
# Bug in imaplib: empty strings in results from
|
||||||
# literals. TODO: still relevant?
|
# literals. TODO: still relevant?
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
flags, delim, name = imaputil.imapsplit(s)
|
flags, delim, name = imaputil.imapsplit(s)
|
||||||
|
except ValueError:
|
||||||
|
self.ui.error(
|
||||||
|
"could not correctly parse server response; got: %s"% s)
|
||||||
|
raise
|
||||||
flaglist = [x.lower() for x in imaputil.flagsplit(flags)]
|
flaglist = [x.lower() for x in imaputil.flagsplit(flags)]
|
||||||
if '\\noselect' in flaglist:
|
if '\\noselect' in flaglist:
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user