fix: better mojibake detection for lone multi-byte lead (#1247)

This commit is contained in:
Kainoa Kanter
2026-03-24 01:57:08 -04:00
committed by GitHub
parent b4d133a32f
commit e604dcd94e

View File

@@ -37,6 +37,13 @@ function looksLikeMojibake(value: string): boolean {
}
}
// A lone multi-byte lead with even one valid continuation is mojibake
if (byte >= 0xc2 && byte <= 0xf4) {
if (i + 1 < value.length && isContinuationByte(value.charCodeAt(i + 1))) {
sawUtf8Sequence = true;
}
}
if (byte >= 0xf0 && byte <= 0xf4) {
if (
i + 3 < value.length &&