Fix IMAP emails appearing empty: accept bytearray from aioimaplib literals
aioimaplib stores RFC822 literal data as bytearray in response.lines, not bytes. The extraction loop checked isinstance(line, bytes) which returns False for bytearray, silently dropping every email body and causing all IMAP emails (T-Online, GMX, etc.) to appear empty. Fix: accept (bytes, bytearray) and convert to bytes() immediately so the rest of the pipeline is unaffected. Two new regression tests mirror the real aioimaplib behaviour by passing bytearray as the literal. Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/341f5c82-70f8-438d-91ca-8e906a06c400 Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -383,9 +383,14 @@ class MailProcessor:
|
||||
# [b'<seq> (UID <uid> RFC822 {<size>}', <email_bytes>, b')']
|
||||
# Skip the header line (contains "RFC822") and grab the
|
||||
# first substantive bytes value.
|
||||
#
|
||||
# aioimaplib stores IMAP literal data (the actual email
|
||||
# content) as bytearray, not bytes. We must accept both
|
||||
# types; bytes() converts bytearray so the rest of the
|
||||
# pipeline always receives plain bytes.
|
||||
email_data: Optional[bytes] = None
|
||||
for line in fetch_response.lines:
|
||||
if not isinstance(line, bytes):
|
||||
if not isinstance(line, (bytes, bytearray)):
|
||||
continue
|
||||
if b"RFC822" in line:
|
||||
continue
|
||||
@@ -393,7 +398,7 @@ class MailProcessor:
|
||||
continue
|
||||
if line in (b")", b""):
|
||||
continue
|
||||
email_data = line
|
||||
email_data = bytes(line)
|
||||
break
|
||||
|
||||
if email_data and email_data.strip():
|
||||
|
||||
Reference in New Issue
Block a user