FAILURE MAP
← Case archive

FA-3221 / Markup / Open access

Entity decoding recursively changes literal entity text · case 01

Entity decoding recursively changes literal entity text.

Verified by executionVariant 1 · 4 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The implementation applies an operation whose text or grammar semantics violate this contract: Apply exactly one HTML character-reference decoding pass.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Apply exactly one HTML character-reference decoding pass.

Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.

Case contract

Apply exactly one HTML character-reference decoding pass.

Why this case matters

A local executable model for consumers of structured text; oracle values are authored literals, not outputs copied from the repaired implementation.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return x.replace('&amp;','&').replace('&lt;','<').replace('&gt;','>')
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('&amp;lt;'), '&lt;')
check('boundary 2', solve('&#x1F600;'), '😀')
check('boundary 3', solve('&copy;'), '©')
check('boundary 4', solve('&unknown;'), '&unknown;')
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 fixtureActualExpectedOutcome
boundary 1<&lt;Failed
boundary 2&#x1F600;😀Failed
boundary 3&copy;©Failed
boundary 4&unknown;&unknown;Passed

SHA-256 / 6d4e2e9f4bddbec94217be8779f65679b501679dbaa15738091f461cffc13b35

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return html.unescape(html.unescape(x))
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('&amp;lt;'), '&lt;')
check('boundary 2', solve('&#x1F600;'), '😀')
check('boundary 3', solve('&copy;'), '©')
check('boundary 4', solve('&unknown;'), '&unknown;')
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 fixtureActualExpectedOutcome
boundary 1<&lt;Failed
boundary 2😀😀Passed
boundary 3©©Passed
boundary 4&unknown;&unknown;Passed

SHA-256 / faaa33655412476f74d2e771f41c7093fe03d3b2bd08a6088902703f82c07188

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json
import re, unicodedata, json, csv, io, html, base64, binascii, codecs, struct
from urllib.parse import quote, unquote, unquote_to_bytes, urlencode, parse_qsl, urlsplit, urlunsplit
from email.header import decode_header, make_header
from email.utils import getaddresses
from xml.etree import ElementTree as ET
import shlex, string, textwrap

N = 1
observations = []
def solve(x):
    try:
        return html.unescape(x)
    except Exception as exc:
        return {"error": type(exc).__name__}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('boundary 1', solve('&amp;lt;'), '&lt;')
check('boundary 2', solve('&#x1F600;'), '😀')
check('boundary 3', solve('&copy;'), '©')
check('boundary 4', solve('&unknown;'), '&unknown;')
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 fixtureActualExpectedOutcome
boundary 1&lt;&lt;Passed
boundary 2😀😀Passed
boundary 3©©Passed
boundary 4&unknown;&unknown;Passed

SHA-256 / 9991cce21fbb4b4082b9836aa292a7070141eb1f40541c9cf29faeab3d0eab4d

Verification & scope

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:37:23.129219+00:00.

Case digest / 79313f027cb6a05710ffb2003c24718f31aa53290741d6d2c89735953ab04671