martinrusev / imbox

Python IMAP for Human beings
MIT License
1.18k stars 188 forks source link

Update parser.py #213

Closed adeelaarbi closed 1 year ago

adeelaarbi commented 2 years ago

Breaking if '=' not in param fixed

sebix commented 2 years ago

Do you have an example mail with this behaviour?

A test case is appreciated.

jimmi2051 commented 2 years ago

I have the same issue. I saw this MR is a good fixing.

  File "/usr/src/app/sap/model_helpers/email_attachment_mixin.py", line 57, in pull_attachments_from_email
    for (uid, message) in unread_inbox_messages:
  File "/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.8/site-packages/imbox/messages.py", line 55, in _fetch_email_list
    yield uid, self._fetch_email(uid)
  File "/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.8/site-packages/imbox/messages.py", line 42, in _fetch_email
    return fetch_email_by_uid(uid=uid,
  File "/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.8/site-packages/imbox/parser.py", line 155, in fetch_email_by_uid
    email_object = parse_email(raw_email, policy=parser_policy)
  File "/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.8/site-packages/imbox/parser.py", line 212, in parse_email
    attachment = parse_attachment(part)
  File "/root/.local/share/virtualenvs/app-lp47FrbD/lib/python3.8/site-packages/imbox/parser.py", line 122, in parse_attachment
    filename_parts.insert(int(s_name[1]),value[1:-1] if value.startswith('"') else value)
ValueError: invalid literal for int() with base 10: ''

I read this email with attachments are image and Docx. And parser has the problem as above. image