FA-76791 / Email MIME structure / Open access
Inject a mailing-list footer without breaking the message: plain text only · case 01
Plain-text footers are appended inside HTML bodies.
ROOT CAUSE
The plain text only decision evaluates `if t.startswith('text/') and` where the contract requires `if t == 'text/plain' and`.
VERIFIED REPAIR
Use `if t == 'text/plain' and` for the plain text only decision and keep every other rule of the model unchanged.
Unsuccessful approach: Treating text/enriched like plain text still appends into formatted content. The attempted `if t in ('text/plain', 'text/enriched') and` still disagrees with a fixture.
Case contract
A top-level text/plain body in 7bit, 8bit or quoted-printable (default 7bit, case-insensitive) gets the footer appended in place ("text+footer"). A multipart/mixed gets a text/plain footer part appended after its children. Everything else (alternative, signed, encrypted, html, base64 text) is wrapped: mixed(<type>,text/plain). Output is a compact structure string.
Why this case matters
List managers that edit signed or encoded bodies in place break signatures and corrupt content.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(node):
t = node['type'].lower()
cte = (node.get('cte') or '7bit').lower()
if t.startswith('text/') and cte in ('7bit', '8bit', 'quoted-printable'):
return 'text+footer'
if t == 'multipart/mixed':
return 'mixed(' + ','.join(c['type'].lower() for c in node['parts']) + ',text/plain)'
return 'mixed(' + t + ',text/plain)'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,text/plain)')], 2: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,text/plain)')], 3: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,text/plain)')], 4: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,image/png,text/plain)')], 5: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,image/png,image/png,text/plain)')]}
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 |
|---|---|---|---|
| base64 text body | mixed(text/plain,text/plain) | mixed(text/plain,text/plain) | Passed |
| quoted-printable text body | text+footer | text+footer | Passed |
| signed message | mixed(multipart/signed,text/plain) | mixed(multipart/signed,text/plain) | Passed |
| encrypted message | mixed(multipart/encrypted,text/plain) | mixed(multipart/encrypted,text/plain) | Passed |
| html body | text+footer | mixed(text/html,text/plain) | Failed |
| enriched body | text+footer | mixed(text/enriched,text/plain) | Failed |
| mixed message | mixed(text/plain,image/png,text/plain) | mixed(text/plain,image/png,text/plain) | Passed |
SHA-256 / a21a1e5f3f228e1a26834511cf3d98319ae207ea8675255c237bd942081cb616
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(node):
t = node['type'].lower()
cte = (node.get('cte') or '7bit').lower()
if t in ('text/plain', 'text/enriched') and cte in ('7bit', '8bit', 'quoted-printable'):
return 'text+footer'
if t == 'multipart/mixed':
return 'mixed(' + ','.join(c['type'].lower() for c in node['parts']) + ',text/plain)'
return 'mixed(' + t + ',text/plain)'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,text/plain)')], 2: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,text/plain)')], 3: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,text/plain)')], 4: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,image/png,text/plain)')], 5: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,image/png,image/png,text/plain)')]}
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 |
|---|---|---|---|
| base64 text body | mixed(text/plain,text/plain) | mixed(text/plain,text/plain) | Passed |
| quoted-printable text body | text+footer | text+footer | Passed |
| signed message | mixed(multipart/signed,text/plain) | mixed(multipart/signed,text/plain) | Passed |
| encrypted message | mixed(multipart/encrypted,text/plain) | mixed(multipart/encrypted,text/plain) | Passed |
| html body | mixed(text/html,text/plain) | mixed(text/html,text/plain) | Passed |
| enriched body | text+footer | mixed(text/enriched,text/plain) | Failed |
| mixed message | mixed(text/plain,image/png,text/plain) | mixed(text/plain,image/png,text/plain) | Passed |
SHA-256 / 4103b90e60695fec63c3f5cf4c924d99856e101b6a96875e2dd3baeca96e1c8f
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(node):
t = node['type'].lower()
cte = (node.get('cte') or '7bit').lower()
if t == 'text/plain' and cte in ('7bit', '8bit', 'quoted-printable'):
return 'text+footer'
if t == 'multipart/mixed':
return 'mixed(' + ','.join(c['type'].lower() for c in node['parts']) + ',text/plain)'
return 'mixed(' + t + ',text/plain)'
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
_CASES = {1: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,text/plain)')], 2: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,text/plain)')], 3: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,text/plain)')], 4: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,image/png,text/plain)')], 5: [('base64 text body', ({'type': 'text/plain', 'cte': 'BASE64'},), 'mixed(text/plain,text/plain)'), ('quoted-printable text body', ({'type': 'text/plain', 'cte': 'quoted-printable'},), 'text+footer'), ('signed message', ({'type': 'multipart/signed', 'parts': [{'type': 'text/plain'}, {'type': 'application/pgp-signature'}]},), 'mixed(multipart/signed,text/plain)'), ('encrypted message', ({'type': 'multipart/encrypted', 'parts': [{'type': 'application/pgp-encrypted'}, {'type': 'application/octet-stream'}]},), 'mixed(multipart/encrypted,text/plain)'), ('html body', ({'type': 'text/html'},), 'mixed(text/html,text/plain)'), ('enriched body', ({'type': 'text/enriched', 'cte': '7bit'},), 'mixed(text/enriched,text/plain)'), ('mixed message', ({'type': 'multipart/mixed', 'parts': [{'type': 'text/plain'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}, {'type': 'image/png'}]},), 'mixed(text/plain,image/png,image/png,image/png,image/png,image/png,text/plain)')]}
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 |
|---|---|---|---|
| base64 text body | mixed(text/plain,text/plain) | mixed(text/plain,text/plain) | Passed |
| quoted-printable text body | text+footer | text+footer | Passed |
| signed message | mixed(multipart/signed,text/plain) | mixed(multipart/signed,text/plain) | Passed |
| encrypted message | mixed(multipart/encrypted,text/plain) | mixed(multipart/encrypted,text/plain) | Passed |
| html body | mixed(text/html,text/plain) | mixed(text/html,text/plain) | Passed |
| enriched body | mixed(text/enriched,text/plain) | mixed(text/enriched,text/plain) | Passed |
| mixed message | mixed(text/plain,image/png,text/plain) | mixed(text/plain,image/png,text/plain) | Passed |
SHA-256 / aa0cf18ed62290d1a299e4e3f7be4f347f873cdf7f2a15ecedfe487c48f1cd52
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:19.394747+00:00.
Case digest / 9f39e35a0d4d1dfe12d5f74bf0cd4812a402f376b33b5eb1388885fd29727992