Fix UTF-8 false-positive on short probes with tolerated errors (regression from #2882 + #2878) - #2888
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a CI regression introduced by the interaction of #2878 and #2882:
utf8Toleratedpath: when a probe isNOT_UTF8but has ≤UTF8_MAX_TOLERATED_ERRORSerror events, the UTF-8 NB result is kept (not disqualified) and a STRUCTURAL UTF-8 candidate is also emitted."the name is \u00e1ndre"in ISO-8859-1 (17 bytes, 1 UTF-8 error event) was being promoted to STRUCTURAL UTF-8, which then short-circuited JunkFilter, preventing it from comparing UTF-8 vs windows-1252. Result: UTF-8 returned instead of windows-1252.Fix: Only emit the STRUCTURAL UTF-8 candidate for
LIKELY_UTF8(definitively clean grammar). Forutf8Tolerated(NOT_UTF8 but within tolerance), NB's UTF-8 result is already kept as a STATISTICAL candidate — JunkFilter has enough signal to arbitrate correctly between UTF-8 and windows-1252.Failing tests fixed:
TXTParserTest.testUseIncomingCharsetAsHintandTXTParserTest.testUsingCharsetInContentTypeHeader.