standard library email.parser fails to recognize multipart message
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
If an email message with attachments contain a boundary with the characters "<--- ... --->" the email.parser module fails to recognize the message as being multipart.
I have attached to this bug report an example mailbox file, and when the following snippet is run on it you will see that is_multipart() returns False, although the message is clearly a multipart message.
I found this boundary string used in a real life email I received.
from email.parser import Parser
# Create parser instance
P = Parser()
with open("message-error.mbox") as f:
msg = P.parse(f)
print(msg.is_multipart())
CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
- gh-135891
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied message-error.txt mailbox and the email.parser Parser snippet, then inspect multipart boundary handling in the standard library. Review linked PR gh-135891 for the work already underway. Done means the example is recognized as multipart and msg.is_multipart() returns True.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100