1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-10 06:48:19 +02:00

Fix reading message id and size when returned in reversed order

This commit is contained in:
Matti Lehtinen 2020-08-28 15:56:10 +03:00
parent c8751f0c9a
commit b786f3d4a9

View file

@ -82,8 +82,14 @@ class ImapTransport(EmailTransport):
for each_msg in data: for each_msg in data:
each_msg = each_msg.decode() each_msg = each_msg.decode()
try: try:
uid = each_msg.split(' ')[2] stripped_msg = each_msg.replace('(', '').replace(')', '')
size = each_msg.split(' ')[4].rstrip(')') split_msg = stripped_msg.split(' ')
for i, s in enumerate(split_msg):
if s == 'UID':
uid = split_msg[i + 1]
elif s == 'RFC822.SIZE':
size = split_msg[i + 1]
if int(size) <= int(self.max_message_size): if int(size) <= int(self.max_message_size):
safe_message_ids.append(uid) safe_message_ids.append(uid)
except ValueError as e: except ValueError as e: