FA-3281 / Encodings / Open access
Percent decoding destroys non-UTF8 bytes · case 01
Percent decoding destroys non-UTF8 bytes.
ROOT CAUSE
The implementation applies an operation whose text or grammar semantics violate this contract: Decode percent escapes to raw integer bytes, UTF-8-encoding unescaped Unicode text.
VERIFIED REPAIR
Implement the complete stated contract, including the boundary fixtures: Decode percent escapes to raw integer bytes, UTF-8-encoding unescaped Unicode text.
Unsuccessful approach: The attempted repair handles the primary example but still violates a separate boundary of the same contract.
Case contract
Decode percent escapes to raw integer bytes, UTF-8-encoding unescaped Unicode text.
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 list(unquote(x).encode('utf-8'))
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('%FF'), [255])
check('boundary 2', solve('é'), [195, 169])
check('boundary 3', solve('%00'), [0])
check('boundary 4', solve('%ZZ'), [37, 90, 90])
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 |
|---|---|---|---|
| boundary 1 | [239, 191, 189] | [255] | Failed |
| boundary 2 | [195, 169] | [195, 169] | Passed |
| boundary 3 | [0] | [0] | Passed |
| boundary 4 | [37, 90, 90] | [37, 90, 90] | Passed |
SHA-256 / 2f19fb1ed714cb43fad224cdf92a912f0012670efe8a2888313edeaaed307ce8
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 list(x.encode('utf-8'))
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('%FF'), [255])
check('boundary 2', solve('é'), [195, 169])
check('boundary 3', solve('%00'), [0])
check('boundary 4', solve('%ZZ'), [37, 90, 90])
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 |
|---|---|---|---|
| boundary 1 | [37, 70, 70] | [255] | Failed |
| boundary 2 | [195, 169] | [195, 169] | Passed |
| boundary 3 | [37, 48, 48] | [0] | Failed |
| boundary 4 | [37, 90, 90] | [37, 90, 90] | Passed |
SHA-256 / 44d5257797362ce1437b92d211f5f40be3ac74e2c7d9d8cc7f917c3f952a3c07
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 list(unquote_to_bytes(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('%FF'), [255])
check('boundary 2', solve('é'), [195, 169])
check('boundary 3', solve('%00'), [0])
check('boundary 4', solve('%ZZ'), [37, 90, 90])
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 |
|---|---|---|---|
| boundary 1 | [255] | [255] | Passed |
| boundary 2 | [195, 169] | [195, 169] | Passed |
| boundary 3 | [0] | [0] | Passed |
| boundary 4 | [37, 90, 90] | [37, 90, 90] | Passed |
SHA-256 / 7a2678f52ec0bd1f230c9106793b2f86bc8d08496db6c168a79bafa92480040a
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.574496+00:00.
Case digest / 1b7ef799f0e45c5c0d34c4d31b37c217868683b4490a96ab6e8776eac64643e9