FAILURE MAP
← Case archive

FA-3216 / Markup / Open access

Text-node escaping rewrites ordinary quotes · case 01

Text-node escaping rewrites ordinary quotes.

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: Escape HTML text ampersands and brackets but leave quote characters literal.

VERIFIED REPAIR

Implement the complete stated contract, including the boundary fixtures: Escape HTML text ampersands and brackets but leave quote characters literal.

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

Case contract

Escape HTML text ampersands and brackets but leave quote characters literal.

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 html.escape(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('"x"'), '"x"')
check('boundary 2', solve("'&'"), "'&'")
check('boundary 3', solve('<a>'), '&lt;a&gt;')
check('boundary 4', solve('plain'), 'plain')
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&quot;x&quot;"x"Failed
boundary 2&#x27;&amp;&#x27;'&amp;'Failed
boundary 3&lt;a&gt;&lt;a&gt;Passed
boundary 4plainplainPassed

SHA-256 / 6da73d4a4dedaaefd9aac525e99fe5d98065258ecb56ee98547b402a804a5546

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 x.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('"x"'), '"x"')
check('boundary 2', solve("'&'"), "'&amp;'")
check('boundary 3', solve('<a>'), '&lt;a&gt;')
check('boundary 4', solve('plain'), 'plain')
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"x""x"Passed
boundary 2'&''&amp;'Failed
boundary 3&lt;a&gt;&lt;a&gt;Passed
boundary 4plainplainPassed

SHA-256 / 0d31444564bbc1365ce9c1da9e5d77e3a252ea230128f5eb9ec3b0f2a8089304

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.escape(x,quote=False)
    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('"x"'), '"x"')
check('boundary 2', solve("'&'"), "'&amp;'")
check('boundary 3', solve('<a>'), '&lt;a&gt;')
check('boundary 4', solve('plain'), 'plain')
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"x""x"Passed
boundary 2'&amp;''&amp;'Passed
boundary 3&lt;a&gt;&lt;a&gt;Passed
boundary 4plainplainPassed

SHA-256 / b8e25b5e88223f97ad0c8035ada447bf30d074319b07ab1e151f4db4779721a4

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

Case digest / 872787131572908a4c8e4e0147792af5c5cab3cf4048bb05b64532858bd65b6b