Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reading message id and size when returned in reversed order by IMAP server #232

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions django_mailbox/transports/imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ def _get_small_message_ids(self, message_ids):
for each_msg in data:
each_msg = each_msg.decode()
try:
uid = each_msg.split(' ')[2]
size = each_msg.split(' ')[4].rstrip(')')
stripped_msg = each_msg.replace('(', '').replace(')', '')
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):
safe_message_ids.append(uid)
except ValueError as e:
Expand Down