gh-156444: Fix a negated character set with IGNORECASE and LOCALE - #156445
Merged
serhiy-storchaka merged 1 commit intoAug 27, 2026
Merged
Conversation
charset_loc_ignore() tested the whole set once per locale case and took the disjunction, which complements a set before closing it under case instead of after: [bc] matched b'B', but so did [^bc]. Match both cases of the character against every set member instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15. |
|
GH-156456 is a backport of this pull request to the 3.15 branch. |
|
GH-156457 is a backport of this pull request to the 3.14 branch. |
|
GH-156458 is a backport of this pull request to the 3.13 branch. |
serhiy-storchaka
added a commit
that referenced
this pull request
Aug 27, 2026
…ALE (GH-156445) (GH-156457) charset_loc_ignore() tested the whole set once per locale case and took the disjunction, which complements a set before closing it under case instead of after: [bc] matched b'B', but so did [^bc]. Match both cases of the character against every set member instead. (cherry picked from commit 6671d27) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
serhiy-storchaka
added a commit
that referenced
this pull request
Aug 27, 2026
…ALE (GH-156445) (GH-156458) charset_loc_ignore() tested the whole set once per locale case and took the disjunction, which complements a set before closing it under case instead of after: [bc] matched b'B', but so did [^bc]. Match both cases of the character against every set member instead. (cherry picked from commit 6671d27) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
charset_loc_ignore()tested the whole set once per locale case and returned true if either test matched. That complements a set before closing it under case rather than after, so[bc]matchedb'B'and[^bc]matched it too.It now walks the set itself and tries both cases for every member, which puts the closure on the members and leaves
NEGATEcomplementing the closed set.SRE(charset)is untouched, and an uncased character short-circuits straight into it.BIGCHARSETandRANGE_UNI_IGNOREare not handled: neither can occur in the set of a bytes pattern, andre.LOCALErejects str patterns.This also fixes gh-155985. The difference fusion is safe once the engine handles an embedded
NEGATEcorrectly, so the workaround in GH-155993 is no longer needed: