Repository navigation
fix(executor): expand non-ASCII bracket members to UTF-8 byte escapes in C locale (Refs #3791) - #3822
Merged
Conversation
… in C locale (Refs #3791)
Member
Author
|
【WIN-AGENT-AUDIT】 机制核查:
腿(逐项给数字与名字):
F 点:无 未跑/VOID 的腿:
|
Member
Author
|
【WIN-AGENT-AUDIT】更正(复核补充):
结论维持:建议 PASS,且 GNU 对照腿升级为全等(15/15 + 尾部 6/6)。 |
caomengxuan666
marked this pull request as ready for review
November 17, 2026 03:41
Member
Author
|
【WIN-AGENT-BATCH-SUMMARY】Y2 波 4 条 draft 审核完毕(2026-11-17)
要点:
|
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.
Root cause
In the C locale
[[ =~ ]]rejected every bracket expression holding a non-ASCII character withinvalid regular expression. GNU anchor:lib/sh/shmatch.c:79-86—sh_regmatch()callsregcomp()withREG_EXTENDEDonly; in the C locale glibc reads pattern and subject as bytes, so a literal multibyte char inside a bracket is the set of its UTF-8 bytes ([é]= {0xC3, 0xA9}).Rubash compiles
[[ =~ ]]patterns inExecutor::compile_conditional_regex_uncached(src/executor/conditional.rs), which in byte mode builds aregex::bytes::Regexwith.unicode(false). The regex crate rejects every non-ASCII char inside a character class in that mode ("Unicode not allowed here"), so every bracket holding a non-ASCII literal or range failed to compile.Fix
In byte mode only, after the POSIX bracket translation and the ERE quantifier rewrite, expand every non-ASCII char to its
\xHHbyte escapes (expand_non_ascii_to_byte_escapes). Ranges then resolve on bytes exactly as glibc resolves them; a backslash before a non-ASCII char is dropped (glibc reads\+ byte as the literal byte; the crate rejects\é). Single choke point:compile_conditional_regex_uncachedis the only regex-compile site for all three=~paths. No change in UTF-8 locales, no change tosrc/lexer/continuation.rsordocs/api-ledger.md, no trust/signing/load-time-check mechanism.Regression nail
tests/issue3791_regex_bracket_nonascii_clocale_regressions.rs: C-locale case (15 assertions, incl. the issue seed 10 + GNU-verified extras) and a C.utf8 control. Fail-first on base: C-locale test FAILED as predicted (every non-ASCII-bracket case returned 2, controls passed). Post-fix: 2/2 tests pass on X299-2607 (Windows MSVC cargo 1.99.1).Verification (X299-2607)
RUSTFLAGS="-D warnings" cargo check --locked --lib --bins: clean.cargo test --locked --lib: 1368 passed / 1 failed / 4 ignored — identical to base; the single failure (api::consumer_tests::issue2084_session_end_restores_host_process_state) is pre-existing on base too.rustfmt --check, marker lint, UTF-8 boundary hygiene: all clean.本 PR 删除了什么
Nothing. Pure addition: one byte-mode expansion helper + one regression test file. No code, test, or public API removed.
Residual (out of scope, documented in the nail file header)
A lone invalid byte as the SUBJECT (
[[ $'\xc3' =~ [é] ]], GNU m1) still does not match — the subject reaches the byte-mode matcher as a U+E000 raw-byte marker pair, not the raw byte. That is the subject-side marker decoding face, adjacent to #3545; it needs its own fix + nails.UNVERIFIED-BY-CAPTAIN