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 ignored headers + unnecessary major version check #206

Merged
merged 2 commits into from
Aug 10, 2021
Merged
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
7 changes: 3 additions & 4 deletions imbox/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import chardet
import base64
import quopri
import sys
import time
from datetime import datetime
from email.header import decode_header
Expand Down Expand Up @@ -155,7 +154,8 @@ def fetch_email_by_uid(uid, connection, parser_policy):
message, data = connection.uid('fetch', uid, '(BODY.PEEK[] FLAGS)')
logger.debug("Fetched message for UID {}".format(int(uid)))

raw_headers, raw_email = data[0]
raw_headers = data[0][0] + data[1]
raw_email = data[0][1]

email_object = parse_email(raw_email, policy=parser_policy)
flags = parse_flags(raw_headers.decode())
Expand All @@ -168,8 +168,7 @@ def parse_flags(headers):
"""Copied from https://github.com/girishramnani/gmail/blob/master/gmail/message.py"""
if len(headers) == 0:
return []
if sys.version_info[0] == 3:
headers = bytes(headers, "ascii")
headers = bytes(headers, "ascii")
return list(imaplib.ParseFlags(headers))


Expand Down