Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Bug report
A valid multipart email message, when parsed withemail.parser.HeaderParser(policy=email.policy.default) will record aemail.errors.MultipartInvariantViolationDefect.
If the parser isn't going to attempt to parse the message body, it shouldn't report that as a defect.
Simple test script:
importemail.parserimportemail.policyemail_str='''\Date: 01 Jan 2001 00:01+0000From: arthur@example.exampleMIME-Version: 1.0Content-Type: multipart/mixed; boundary=autocracy--autocracyContent-Type: text/plainBy hanging on to outdated imperialist dogma which perpetuates the economic andsocial differences in our society.--autocracyContent-Type: text/html<html><body><p>By hanging on to outdated imperialist dogma which perpetuatesthe economic and social differences in our society.</p></body></html>--autocracy--'''full_parser=email.parser.Parser(policy=email.policy.default)parsed_email_full=full_parser.parsestr(email_str)print(parsed_email_full.defects)# Prints [] as expectedheader_parser=email.parser.HeaderParser(policy=email.policy.default)parsed_email_headers_only=header_parser.parsestr(email_str)print(parsed_email_headers_only.defects)# Prints [MultipartInvariantViolationDefect()]
Your environment
- Debian 12
- Raspberry Pi 4 (arm64)
- Python 3.11.2 (Debian package 3.11.2-1+b1)
Linked PRs
- gh-106186: Don't report MultipartInvariantViolationDefect for valid multipart emails when parsing header only #107016
- [3.12] gh-106186: Don't report MultipartInvariantViolationDefect for valid multipart emails when parsing header only (GH-107016) #107111
- [3.11] gh-106186: Don't report MultipartInvariantViolationDefect for valid multipart emails when parsing header only (GH-107016) #107112