Skip to content

fix(compliance): restore corrupted em-dashes and detect CP437 mojibake - #186

Merged
josealekhine merged 1 commit into
mainfrom
fix/mojibake-cp437
Oct 6, 2026
Merged

josealekhine merged 1 commit into
mainfrom
fix/mojibake-cp437

Conversation

@josealekhine

@josealekhine josealekhine commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Every em-dash in compliance_test.go's section headers had been
double-encoded through CP437 (the Windows console code page) into a
six-character garble, 21 times over. TestNoMojibake, which lives in
that same file, matched only the Windows-1252 signature (C3 A2 E2),
so it passed on its own corruption.

Restore the em-dashes and give the detector two more signatures:
single CP437 (CE 93 C3) and CP437 applied twice (E2 95 AC C3 B4).
Each is the garbled form of UTF-8 lead byte 0xE2, which every
dash, quote, ellipsis, and arrow shares, so none occurs in real
text. The failure message names the code page. The doc comment
spells its examples as code points, since the literal forms would
trip the test on its own file.

Also: build the failure-context slice with max/min (the old code
gave no leading context for a match in the first 20 bytes), and
make the allGoFiles doc comment list all five skipped directories
instead of only vendor/.

Spec: specs/mojibake-cp437-detection.md

Every em-dash in compliance_test.go's section headers had been
double-encoded through CP437 (the Windows console code page) into a
six-character garble, 21 times over. TestNoMojibake, which lives in
that same file, matched only the Windows-1252 signature (C3 A2 E2),
so it passed on its own corruption.

Restore the em-dashes and give the detector two more signatures:
single CP437 (CE 93 C3) and CP437 applied twice (E2 95 AC C3 B4).
Each is the garbled form of UTF-8 lead byte 0xE2, which every
dash, quote, ellipsis, and arrow shares, so none occurs in real
text. The failure message names the code page. The doc comment
spells its examples as code points, since the literal forms would
trip the test on its own file.

Also: build the failure-context slice with max/min (the old code
gave no leading context for a match in the first 20 bytes), and
make the allGoFiles doc comment list all five skipped directories
instead of only vendor/.

Spec: specs/mojibake-cp437-detection.md
Signed-off-by: Jose Alekhinne <jose@ctx.ist>
@josealekhine josealekhine self-assigned this Oct 6, 2026
@josealekhine
josealekhine merged commit 095277d into main Oct 6, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant