Repository navigation
Refs #3104: fold raw-byte (E000) pairs at name-consumption boundaries - #3122
Merged
Merged
Conversation
…aries (Refs #3104) 22 cells mirroring the GNU bash 5.3.20 probe matrix: redirect targets (variable / comsub / ANSI-C forms) with on-disk name-byte assertions, test and [[ ]] operands (unary + binary), source, cd, pushd, the $(cd ...) fast path, PATH lookup, slash-name spawn, exec, type, command-not-found diagnostic, glob literal segments, bind -f, history -w, $(< file), read redirect, plus plain-name and genuine-U+E000 controls. Fail-first on the base: the defect cells fail, the controls pass.
…#3104) fold_literal_char_escapes gated on the E400 introducer alone, so a name carrying only a U+E000 raw-byte pair never folded: the pair spelling reached filesystem probes, lookup cache keys, and diagnostics at every boundary the rubash#3076 census routed through the shared gate + decoder (PATH/hash keys, slash-name classification, cd/pushd operands and substituted values, exec, source, test operands, glob patterns, history/bind/enable file operands, the comsub cd fast path, redirect operand finalization and the failglob diagnostic). The decoder already folds both families; the gate is now the shared double-family gate contains_decodable_transport (rubash#3038) — one gate for the whole census, no per-command patching. GNU ownership: the expanded word IS the name (redir.c:298, findcmd.c:348/623, execute_cmd.c:6139, cd.def:427, source.def:179, test.c:549-559). The $(< file) reader (optimize_cat_file, subst.c:6665 / builtins/evalstring.c:759) finalizes its own word and never passes the shared helper; fold its finalized file_word through the same gate + decoder before the open. The marker-lint allowlist entry for the removed single-family gate line goes with it (stale entry); pin file fmt touch-up.
… scans; pin the p23 high-byte redirect (Refs #3104) The pair-head assertion in redirect_var / redirect_comsub / redirect_ansic / history_write scanned every entry name for the U+E000 pair head, including the fixture's own genuine-U+E000 control file u\u{E000}v (bytes [117, 238, 128, 128, 118]) — the four cells red on any tree, including a tree whose products land the raw-byte names correctly. The scan now skips exactly that known control file. Adds the p23 regression pin (probe p23: a stored 0x9C byte in a redirect target must land as the single raw byte, not UTF-8 re-encoded) and a UTF-8 control pin (a genuine non-ASCII name keeps its UTF-8 bytes). GNU oracle: redir.c:298.
…th bytes (Refs #3104) Two gaps the NOT-PASS review found, plus the p23 high-byte face in the same wave: 1. PATH lookup never folded the directory components: PATH "$PWD/bin\x1cd:$PATH" probed the unfolded pair spelling, so findcmd never saw the byte-named directory. The unix walk now folds each element (gated on the element's own transport) and converts each side to filesystem bytes only when it carried transport; the as-written join stays the folded string spelling for `type`/\$0. The Windows listings scaffold folds its elements the same way (the folded string is already the WTF-8 spelling there). GNU anchor: findcmd.c:348 search_for_command / findcmd.c:623 find_user_command_in_path walk PATH with the element bytes verbatim. 2. p23: a folded byte char >= 0x80 was re-encoded as UTF-8 at every name -> path conversion (0x9C landed as C2 9C; 0x1C passed only because it is < 0x80). A folded name cannot tell a byte char from a genuine char of the same code point, so the pre-fold transport fact is now carried explicitly: the PATH walk takes it as a parameter, redirect targets record it in a per-command memo set keyed by the folded target string, and the $() reader records it at its own fold site. The new folded_name_to_path_bytes / path_buf_from_folded_name funnel emits byte chars as raw bytes and every other char as UTF-8, applied at the redirect output/append/input opens and the $(< file) reader. GNU anchor: redir.c:298 redirection_expand opens the name bytes verbatim. Residual recorded in REPORT: genuine Latin-1 chars mixed into one name with a raw-byte pair share the byte char's code point and take the byte spelling. The same funnel also covers the input-redirect open, the append opens, the <> readwrite opens, and the $(< file) reader.
caomengxuan666
marked this pull request as ready for review
November 9, 2026 11:14
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.
返工完成(队长复核 NOT-PASS 终判 2026-11-09 17:18 CST 的三项,2026-11-09 18:42 CST)
!names.any(pair head)误杀夹具自带的真 U+E000 对照文件u\u{E000}v;改为 pair 扫描排除该已知真字符文件(pair_headedhelper)。只改测试文件,提交e0946497。path_lookup_finds_byte_named_dir_and_commandrc=127、type_reports_raw_byte_path空输出)。根因:PATH 分割/查找消费点未对字节名目录分量折对,findcmd侧未走共享 helper。修法见下,提交6e03cd18。a\x9cbvs 旧头a\xc2\x9cb);字节字符→路径字节按原始字节发射。新增 p23 钉格 + é 对照格,茎由 22 格变为 24 格(基底 fail-first 由 3/19 变为 4/20)。enable -f诊断措辞,记录而已);RUSTFLAGS="-D warnings"rc=0;marker-lint rc=0;fmt rc=0。~/workspace/fix-3104/REPORT.md§5–§6。Refs #3104
问题
存储值中的原始字节以 U+E000 原始字节对(E000 + 载荷字)传输。#3076 在全部名字消费边界以共享门 + 边界解码器折回了 E400 字面转义对,但共享 helper
fold_literal_char_escapes的门只认 E400 引入符——纯 E000 对的文本不触发折叠,于是同一批边界在 E000 域原样泄漏:EE 80 80 EE 80 9D六字节);变量形、comsub 直形、$'...'形同漏(redir.c:298:redirection_expand 返回的串即 open 的串)。test/[/[[ ]]操作数(一元 + 二元)探对名 → 既存文件报假(test.c:549-559)。source(source.def:179)、cd(cd.def:427)、pushd、$(cd … && pwd)快路径解析对名失败。exec(execute_cmd.c:6139 原始词字节)找不到既存可执行文件;type报对拼写。bind -f读对名失败;history -w落对拼写名。$(< file)快路径(optimize_cat_file,subst.c:6665 / evalstring.c:759)自有定型点、不经共享 helper,同样不折对。#3004已在仿真文件内建面以双族门contains_decodable_transport+ 同一解码器修复同域问题;本单是其余名字消费边界的 E000 对应面(#3076 普查 #26 记录域)。修法(按机制)
substitution_metadata::fold_literal_char_escapes的门由「仅 E400 引入符」放宽为双族门markers::contains_decodable_transport(E000 引入符或 E400 引入符,expand_prompt renders the E400 escape pair for a stored U+E314 value instead of the raw char #3038 既有门)——解码器本体decode_raw_byte_markers_to_byte_chars本就双族全解(E000 对 → byte char、E000E000 → 字面 U+E000、E400 对 → 原字)。E400 literal-char pairs leak at command-lookup / slash-execve-classification / cd / exec operand boundaries (same family as #3040) #3076 普查的全部边界(PATH/hash 键、slash 分类、cd/pushd、exec 诊断、source、test、glob、history/bind/enable 文件操作数、comsub cd 快路径、重定向定型与 failglob 诊断)经此一门同解,不按命令逐个打补丁。command_substitution::comsub_cat_file_substitute:$(< file)的词定型后(字段分裂/glob 之后、fs 读之前)在同一 helper 折对——该面是普查中唯一不经共享 helper 的名字消费点。search_for_command/ :623find_user_command_in_path):path.rs::find_in_path_walk_unix对每个 PATH 分量亦经fold_literal_char_escapes折对;目录与命令名按字节拼探测路径(OsStr::from_bytes),as-written 拼写仍为折叠串(type打印 / $0 记录的拼写)。slash与exec面已绿,不动。folded_name_to_path_bytes(U+0000..=U+00FF 的 byte char 发单字节,其余发 UTF-8)+path_buf_from_folded_name;重定向目标在展开点记redirect_target_had_transport(仅字面臂记录,glob/procsub/heredoc 臂不记),经中央输出/追加/输入漏斗与散落的 10 处重定向打开点统一走字节路径。真 UTF-8 名(无 transport)不受影响,由 é 对照格钉住。本 PR 删除了什么
fold_literal_char_escapes的单族门条件(E400-only 把关)——它正是 E000 域在全部共享边界泄漏的单一根因。验证
tests/issue3104_e000_name_consumers.rs(24 格,含落盘名字节断言):头 24/24;基底 fail-first 4 绿 / 20 红,逐格干净(13 机制格 + 4 钉 bug 格 + path_lookup + type + p23 均基底红/头绿;4 绿格为 3 旧双绿 + é 对照)。~/workspace/fix-3104/probes,GNU 5.3.20 / 基底 / 修复树三方):修复后与 GNU 只差 p20 一行(enable -f诊断措辞差异,记录而已,不修不立);p07/p11/p23 均与 GNU 逐字节一致。RUSTFLAGS="-D warnings"rc=0;marker-lint rc=0;fmt rc=0。type对 0x9C 目录的显示仍为 UTF-8 形(p11 为 0x1C,不在范围)。各腿数字见 REPORT(~/workspace/fix-3104/REPORT.md)。