You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
content/mojibake: false positive on valid uppercase Portuguese words ending in "Ã" #1617
Version: 0.0.171 (packages/rules/src/content/mojibake.ts as of 8bcd9e1)
What happens: valid UTF-8 Portuguese text in uppercase, such as "MANHÃ", "IRMÃ" or "MAÇÃ" followed by a space, is reported as utf8-as-latin1 encoding corruption, with the sample "Ã ".
Repro: a page served as UTF-8 (<meta charset="utf-8">, Content-Type: text/html; charset=utf-8) with:
<p>Abrimos de MANHÃ e à tarde.</p>
squirrel audit <url> --offline --rule-include content reports content/mojibake ("2 encoding corruption occurrence(s) in visible text (utf8-as-latin1)", sample "Ã "). The same page with "manhã" in lowercase passes.
Cause:MOJIBAKE_SEQUENCES has "Ã " for "à", written with a regular space (0x20). The UTF-8 bytes of "à" (C3 A0) decoded as latin1/cp1252 give "Ã" + NO-BREAK SPACE (U+00A0), not a regular space. With 0x20 the sequence matches any word ending in "Ã" before a space, which is common in uppercase Portuguese (headings, buttons, opening hours).
Possible fix: match U+00A0 instead of the space. If NBSP is normalised to a space before the rule runs, skip the match when the character before "Ã" is an uppercase letter, so "MANHÃ " counts as valid text while "Ã " after a lowercase letter or at the start of a word still counts as corruption.
Triage
Confirmed on current main. packages/rules/src/content/mojibake.ts lists "Ã " (U+0020) as the mojibake form of "à" in MOJIBAKE_SEQUENCES. Real latin1 decoding of the UTF-8 bytes C3 A0 yields "Ã" plus U+00A0, so the regular-space entry matches any word ending in uppercase "Ã" before a space ("MANHÃ ", "IRMÃ ", "MAÇÃ ").
Acceptance Criteria
<p>Abrimos de MANHÃ e à tarde.</p> served as UTF-8 produces no content/mojibake finding
Text such as "IRMÃ " and "MAÇÃ " produces no finding
Genuine mojibake for "à" (à followed by U+00A0, e.g. "cafà ") is still reported
A regression test covers both the uppercase false positive and the genuine corruption case
The rule's docs page is updated if the matching behaviour is described there
Activity
docs(rules): content/mojibake matches the byte-faithful à + U+00A0 fo…
fix(rules): content/mojibake matches à plus U+00A0, not a regular spa…
docs(rules): content/mojibake matches the byte-faithful à + U+00A0 fo…
style(rules): drop an em-dash from a comment #1617