Repository navigation
WIP: fix(executor): reject non-POSIX class names in =~ (#1717) - #1761
Merged
Merged
Conversation
GNU hands the =~ pattern to libc regcomp (lib/sh/shmatch.c:86 sh_regmatch), whose [:name:] validation is the wctype property table: exactly the twelve POSIX names. `word` and `ascii` are regex-crate Perl classes, not wctype properties, so GNU (glibc and bionic alike) fails them with REG_ECTYPE "Invalid character class name", rc=2 — rubash accepted both and evaluated them. - posix_bracket_class_names_valid: class list 14 -> 12 (the compile gate for both the byte and UTF-8 paths). - regexp_error_reason: same list, so the diagnostic derivation agrees and yields the REG_ECTYPE text. - posix_class_unicode_expansion: drop the `word` arm; under a UTF-8 locale [:word:] previously expanded before validation and never reached the gate. The verbatim span now fails the gate like any other unknown name. The glob matcher is a separate GNU subsystem with its own 14-name table by design (lib/glob/smatch.c:196-200 cclass_name[] carries CC_ASCII/CC_WORD; an unknown glob class is skipped, not an error) — pattern.rs / locale.rs are untouched, and the regression file pins that split as a control group. Regression: tests/issue1717_regex_class_name_regressions.rs — invalid names (word/ascii/foo/Word, negated, via-variable) rc=2 + diagnostic under LC_ALL=C and C.UTF-8, the twelve legal classes unchanged in both modes, non-class bracket shapes stay valid, glob control group.
caomengxuan666
force-pushed
the
fix8/regex-class
branch
from
October 26, 2026 09:13
ce37d76 to
366b946
Compare
caomengxuan666
marked this pull request as ready for review
October 26, 2026 12:33
This was referenced Oct 30, 2026
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.
WIP: #1717 —
[[ =~ ]]accepts[[:word:]]/[[:ascii:]]; GNU rejects both with rc=2Coverage
Refs #1717. Verification and merge go through the integration flow — please do not merge this draft directly.
Baseline (rebased 2026-10-26)
This branch was master
1560ea44+ locale2's three commits cherry-picked (#1622/#1621/#1658). locale2 has since merged as PR #1752 (mergede542703, 2026-10-26 15:48 CST), so the branch was rebased onto current master159e74a7(which containsfafdd352, the master tip named in the rebase order). Rebase was conflict-free: git skipped all three cherry-picks as previously applied (patch-identical to the merged commits), and the #1717 commit's hunks are byte-identical before/after (ce37d765→366b946d). The diff is now exactly the single #1717 commit.Change (src/executor/conditional.rs only)
posix_bracket_class_names_valid) and diagnostic derivation (regexp_error_reason): 14 names → the twelve wctype/POSIX names. GNU owner:lib/sh/shmatch.c:86 sh_regmatch→ libc regcomp;word/asciiare regex-crate Perl classes, not wctype properties → REG_ECTYPE "Invalid character class name", rc=2 (glibc + bionic dual-oracle verified).posix_class_unicode_expansion): drop thewordarm so[[:word:]]reaches the gate verbatim instead of expanding pre-validation.lib/glob/smatch.c:196-200cclass_name[], CC_ASCII/CC_WORD; unknown glob classes are skipped, never errors).pattern.rs/locale.rsunchanged; the regression file pins the split as a control group.Tests
tests/issue1717_regex_class_name_regressions.rs— invalid names (word/ascii/foo/Word, negated, via-variable) rc=2 + diagnostic under LC_ALL=C and C.UTF-8; the twelve legal classes unchanged in both modes; non-class bracket shapes ([:word:]char list) stay valid; glob control group (word/ascii match, foo no-match rc=1).Progress
ownership_unary_operators_check_existing_fileallowed), diffcorpus 306 effective failures ⊆ {ms10}