FA-76406 / Email MIME structure / Open access
Classify leaf parts as body, inline or attachment: explicit attachment first · case 01
An image the sender explicitly attached disappears into the body because the HTML happens to reference it.
ROOT CAUSE
The explicit attachment first decision evaluates `if disp == 'attachment' and p.get('cid') not in html_cids:` where the contract requires `if disp == 'attachment':`.
VERIFIED REPAIR
Use `if disp == 'attachment':` for the explicit attachment first decision and keep every other rule of the model unchanged.
Unsuccessful approach: Exempting images from the explicit disposition has the same effect for referenced images. The attempted `if disp == 'attachment' and not p['type'].startswith('image/'):` still disagrees with a fixture.
Case contract
parts are the leaves of a multipart/mixed message in order: {type, disp, cid, filename}. Rules in order: an explicit "attachment" disposition (case-insensitive) is an attachment even when referenced; a part whose cid is exactly one of html_cids is inline; the first text/* part without a (non-empty) filename is the body; an explicit inline image/* is inline; everything else is an attachment.
Why this case matters
Disposition decides what the reader sees in the message body and what is offered for download.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(parts, html_cids):
out = []
have_body = False
for p in parts:
disp = (p.get('disp') or '').lower()
if disp == 'attachment' and p.get('cid') not in html_cids:
kind = 'attachment'
elif p.get('cid') and p['cid'] in html_cids:
kind = 'inline'
elif p['type'].startswith('text/') and not p.get('filename') and not have_body:
kind = 'body'
have_body = True
elif disp == 'inline' and p['type'].startswith('image/'):
kind = 'inline'
else:
kind = 'attachment'
out.append(kind)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo1@x', 'disp': 'attachment'}], ['logo1@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes1.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a1@x'}, {'type': 'image/png', 'cid': 'ba1@x'}], ['a1@x']), ['body', 'inline', 'attachment'])], 2: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo2@x', 'disp': 'attachment'}], ['logo2@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes2.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a2@x'}, {'type': 'image/png', 'cid': 'ba2@x'}], ['a2@x']), ['body', 'inline', 'attachment'])], 3: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo3@x', 'disp': 'attachment'}], ['logo3@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes3.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a3@x'}, {'type': 'image/png', 'cid': 'ba3@x'}], ['a3@x']), ['body', 'inline', 'attachment'])], 4: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo4@x', 'disp': 'attachment'}], ['logo4@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes4.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a4@x'}, {'type': 'image/png', 'cid': 'ba4@x'}], ['a4@x']), ['body', 'inline', 'attachment'])], 5: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo5@x', 'disp': 'attachment'}], ['logo5@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes5.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a5@x'}, {'type': 'image/png', 'cid': 'ba5@x'}], ['a5@x']), ['body', 'inline', 'attachment'])]}
for _label, _args, _expected in _CASES[N]:
check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| referenced image marked attachment | ['body', 'inline'] | ['body', 'attachment'] | Failed |
| upper-case disposition | ['attachment', 'body'] | ['attachment', 'body'] | Passed |
| second text part | ['body', 'attachment'] | ['body', 'attachment'] | Passed |
| attachment precedes body | ['attachment', 'body', 'attachment'] | ['attachment', 'body', 'attachment'] | Passed |
| named text part | ['attachment', 'body'] | ['attachment', 'body'] | Passed |
| empty filename | ['body'] | ['body'] | Passed |
| inline non-images | ['body', 'attachment', 'attachment', 'inline'] | ['body', 'attachment', 'attachment', 'inline'] | Passed |
| cid substring | ['body', 'inline', 'attachment'] | ['body', 'inline', 'attachment'] | Passed |
SHA-256 / 510259ac72c940e443e00b4c90a2b9c55d5d802ead90e47ede0664efb687160a
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(parts, html_cids):
out = []
have_body = False
for p in parts:
disp = (p.get('disp') or '').lower()
if disp == 'attachment' and not p['type'].startswith('image/'):
kind = 'attachment'
elif p.get('cid') and p['cid'] in html_cids:
kind = 'inline'
elif p['type'].startswith('text/') and not p.get('filename') and not have_body:
kind = 'body'
have_body = True
elif disp == 'inline' and p['type'].startswith('image/'):
kind = 'inline'
else:
kind = 'attachment'
out.append(kind)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo1@x', 'disp': 'attachment'}], ['logo1@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes1.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a1@x'}, {'type': 'image/png', 'cid': 'ba1@x'}], ['a1@x']), ['body', 'inline', 'attachment'])], 2: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo2@x', 'disp': 'attachment'}], ['logo2@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes2.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a2@x'}, {'type': 'image/png', 'cid': 'ba2@x'}], ['a2@x']), ['body', 'inline', 'attachment'])], 3: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo3@x', 'disp': 'attachment'}], ['logo3@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes3.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a3@x'}, {'type': 'image/png', 'cid': 'ba3@x'}], ['a3@x']), ['body', 'inline', 'attachment'])], 4: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo4@x', 'disp': 'attachment'}], ['logo4@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes4.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a4@x'}, {'type': 'image/png', 'cid': 'ba4@x'}], ['a4@x']), ['body', 'inline', 'attachment'])], 5: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo5@x', 'disp': 'attachment'}], ['logo5@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes5.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a5@x'}, {'type': 'image/png', 'cid': 'ba5@x'}], ['a5@x']), ['body', 'inline', 'attachment'])]}
for _label, _args, _expected in _CASES[N]:
check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| referenced image marked attachment | ['body', 'inline'] | ['body', 'attachment'] | Failed |
| upper-case disposition | ['attachment', 'body'] | ['attachment', 'body'] | Passed |
| second text part | ['body', 'attachment'] | ['body', 'attachment'] | Passed |
| attachment precedes body | ['attachment', 'body', 'attachment'] | ['attachment', 'body', 'attachment'] | Passed |
| named text part | ['attachment', 'body'] | ['attachment', 'body'] | Passed |
| empty filename | ['body'] | ['body'] | Passed |
| inline non-images | ['body', 'attachment', 'attachment', 'inline'] | ['body', 'attachment', 'attachment', 'inline'] | Passed |
| cid substring | ['body', 'inline', 'attachment'] | ['body', 'inline', 'attachment'] | Passed |
SHA-256 / bea6f40c7235093b752aa40f27058eab58e0d4ce0cb16e67457c4a1f25f41a62
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(parts, html_cids):
out = []
have_body = False
for p in parts:
disp = (p.get('disp') or '').lower()
if disp == 'attachment':
kind = 'attachment'
elif p.get('cid') and p['cid'] in html_cids:
kind = 'inline'
elif p['type'].startswith('text/') and not p.get('filename') and not have_body:
kind = 'body'
have_body = True
elif disp == 'inline' and p['type'].startswith('image/'):
kind = 'inline'
else:
kind = 'attachment'
out.append(kind)
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo1@x', 'disp': 'attachment'}], ['logo1@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes1.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a1@x'}, {'type': 'image/png', 'cid': 'ba1@x'}], ['a1@x']), ['body', 'inline', 'attachment'])], 2: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo2@x', 'disp': 'attachment'}], ['logo2@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes2.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a2@x'}, {'type': 'image/png', 'cid': 'ba2@x'}], ['a2@x']), ['body', 'inline', 'attachment'])], 3: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo3@x', 'disp': 'attachment'}], ['logo3@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes3.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a3@x'}, {'type': 'image/png', 'cid': 'ba3@x'}], ['a3@x']), ['body', 'inline', 'attachment'])], 4: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo4@x', 'disp': 'attachment'}], ['logo4@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes4.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a4@x'}, {'type': 'image/png', 'cid': 'ba4@x'}], ['a4@x']), ['body', 'inline', 'attachment'])], 5: [('referenced image marked attachment', ([{'type': 'text/plain'}, {'type': 'image/png', 'cid': 'logo5@x', 'disp': 'attachment'}], ['logo5@x']), ['body', 'attachment']), ('upper-case disposition', ([{'type': 'text/plain', 'disp': 'ATTACHMENT'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('second text part', ([{'type': 'text/plain'}, {'type': 'text/plain'}], []), ['body', 'attachment']), ('attachment precedes body', ([{'type': 'application/pdf', 'disp': 'attachment'}, {'type': 'text/plain'}, {'type': 'text/plain'}], []), ['attachment', 'body', 'attachment']), ('named text part', ([{'type': 'text/plain', 'filename': 'notes5.txt'}, {'type': 'text/plain'}], []), ['attachment', 'body']), ('empty filename', ([{'type': 'text/plain', 'filename': ''}], []), ['body']), ('inline non-images', ([{'type': 'text/html'}, {'type': 'application/pdf', 'disp': 'inline'}, {'type': 'audio/ogg', 'disp': 'inline'}, {'type': 'image/gif', 'disp': 'inline'}], []), ['body', 'attachment', 'attachment', 'inline']), ('cid substring', ([{'type': 'text/html'}, {'type': 'image/png', 'cid': 'a5@x'}, {'type': 'image/png', 'cid': 'ba5@x'}], ['a5@x']), ['body', 'inline', 'attachment'])]}
for _label, _args, _expected in _CASES[N]:
check(_label, solve(*_args), _expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| referenced image marked attachment | ['body', 'attachment'] | ['body', 'attachment'] | Passed |
| upper-case disposition | ['attachment', 'body'] | ['attachment', 'body'] | Passed |
| second text part | ['body', 'attachment'] | ['body', 'attachment'] | Passed |
| attachment precedes body | ['attachment', 'body', 'attachment'] | ['attachment', 'body', 'attachment'] | Passed |
| named text part | ['attachment', 'body'] | ['attachment', 'body'] | Passed |
| empty filename | ['body'] | ['body'] | Passed |
| inline non-images | ['body', 'attachment', 'attachment', 'inline'] | ['body', 'attachment', 'attachment', 'inline'] | Passed |
| cid substring | ['body', 'inline', 'attachment'] | ['body', 'inline', 'attachment'] | Passed |
SHA-256 / 2acfea1345e09119285fb28ee09392f1534e048123e83675b1bf5f1d465ca00c
Verification & scope
Stipulated offline model over pre-parsed MIME dictionaries; not a conforming MIME parser, generator or mail client. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:16.005828+00:00.
Case digest / f58f273a37540fe3e1d4689ee9ed791bc42d62a72184ab70f6492bd19c57e569