FA-76431 / Email MIME structure / Open access
Classify leaf parts as body, inline or attachment: exact cid reference · case 01
Every part carrying a Content-ID is hidden inline even when the HTML never references it.
ROOT CAUSE
The exact cid reference decision evaluates `True` where the contract requires `p['cid'] in html_cids`.
VERIFIED REPAIR
Use `p['cid'] in html_cids` for the exact cid reference decision and keep every other rule of the model unchanged.
Unsuccessful approach: Substring matching treats "ba@x" as a reference to "a@x". The attempted `any(c in p['cid'] for c in html_cids)` 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':
kind = 'attachment'
elif p.get('cid') and True:
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', 'inline'] | ['body', 'inline', 'attachment'] | Failed |
SHA-256 / fd676984f0db552dcbde672932fd8e0235d4639661588c10b0c904d4034b67ff
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':
kind = 'attachment'
elif p.get('cid') and any(c in p['cid'] for c 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', 'inline'] | ['body', 'inline', 'attachment'] | Failed |
SHA-256 / 70424b0bd1883d386b0229b94dc370ee482f5ce7d564440116d4cd1cc4409c41
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.138810+00:00.
Case digest / 5b12e4393ae7bd457e4d19bdafc9d1a89fb4b7db8fe0ee3961d63f81f8ef4623