Skip to content

fix: fold the E400 pair at the name boundaries — not-found diagnostic + redirect filename (Refs #3040) - #3075

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/3040-e400-name-boundaries
Nov 8, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/3040-e400-name-boundaries

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #3040 — UNVERIFIED-BY-CAPTAIN

根因

存储的注册区字符(如 $'\uE314')在传输形态下以 E400 字面转义对(U+E400 + 该字符)承载。两个「值用作名字」的边界从未把这对折回原始字符:

  1. 命令未找到诊断:printable_filename(src/executor/execution_misc.rs)的未引号分支原样返回传输文本,于是诊断印出 E400 对而非原始字符。GNU 锚点:execute_cmd.c:5909(execute_disk_command)对原始词跑 printable_filename(general.c:1040),可打印则原样印原始字节。探针(LC_ALL=C.UTF-8,GNU 5.3.20):诊断名 = EE 8C 94;基底 rubash = EE 90 80 EE 8C 94。
  2. 重定向目标文件名:expand_redirect_operand_fields 的字面操作数收尾(redirect_operand_literal)解码了词位载体与 IFS guard,但 E400 对被 E400-aware 的恢复链刻意保留,径直落盘成文件名。GNU 锚点:redir.c:298 redirection_expand 返回的字符串被 do_redirection_internal 逐字打开。基底落盘名 = E400 对字节;GNU = 原始字符名。

修法(按机制、复用 #2881 解码路径)

两处都调用外部边界已确立的同一解码器 substitution_metadata::decode_raw_byte_markers_to_byte_chars(#2881 在 argv/env 边界确立),只调用、不改形;且都以「含 U+E400 引入符」为门,无 marker 的名字/文件名逐字节不动:

  • printable_filename 未引号分支折对——该函数是两处诊断点位(external_inner、pipeline_stages)的共同入口,一处修两处齐。
  • redirect_operand_literal 在操作数定型为文件名处折对(新增小 helper fold_filename_literal_char_escapes);failglob 的 no match: 诊断命名的正是同一操作数,同 helper 一并折。重定向 open 错误诊断经 memoized target 继承本修(探针已核:> "$v/sub" 的诊断名由对变原始字符)。
  • E7 lint allowlist 补两条 contains:LITERAL_CHAR_ESCAPE presence-gate 条目(与既有同型条目同措辞);lint OK(117 consts / 260 sites)。

钉子:diagnostics_carry_no_markers 的两腿原为 inverted pin(断言错误输出),本 PR 改回 GNU 断言——cnf 腿断言诊断含原始字符且不含 U+E400;redirect 腿断言落盘名恰为原始字符名。bad-substitution 腿与 prompts 等其他格未动。

队长复核项(车道自报)

  • Fail-first:仅改钉的树上 diagnostics_carry_no_markers 翻红(panic 于 cnf 腿:诊断印 \u{e400}\u{e314});redirect 腿基底失败由字节探针证(落盘名 EE 90 80 EE 8C 94)。
  • 修后:golden 全茎 20 passed / 0 failed;registry 茎 10/0;lib 1200/0/4;邻茎 cat_redirect_stream 2/0、issue0113_redir_fd 6/0、issue1127 1/0、issue1208 3/0。
  • 邻茎两处红与基底同名同形、已 stash 对照证为既存环境形:deep_audit_b6_diagnostics 的 b6_f2_times_diagnostic_prefix(7/1,基底同 panic)、issue1025…redirect_fd 的 issue_1967_* 两格(14/2,基底同失败;/dev/tcp 计数服务器在本沙箱收不到连接)。
  • RUSTFLAGS="-D warnings" check rc=0;fmt rc=0;hygiene clean;CR 零;marker-lint OK;api-ledger 281 符号全在(账本未动)。
  • 修后二进制探针(对 GNU 5.3.20 逐字节):cnf 诊断、重定向落盘名、open 错误诊断名、failglob 诊断名四形全 SAME。

同族普查(仅报告、未修,留队长立案)

同一类别(存储 E400 对在名字/文件名边界未解码)在基底上另命中四处,均经探针与 GNU 对照证实,本 PR 未动:

  1. 命令 PATH 查找:v=$'\uE314'; "$v",PATH 里存在原始字符名的可执行文件时 GNU 正常运行、rubash 报 command not found(查找用的是对名)。
  2. slash 名 execve 分类:./$v 指向已存在不可执行文件时 GNU 报 Permission denied(126),rubash 报 No such file or directory(127)——slash_command_execve_error_message 的 metadata 探查用的对名(其诊断显示面已随本 PR 的 printable_filename 修法变正确,分类面未动)。
  3. cd 操作数:cd "$v" 进原始字符名目录,GNU 成功,rubash 报 No such file or directory 且诊断印对。
  4. exec 内建诊断:exec "$v" 失败时 GNU 印 exec: <原始字符>: not found,rubash 印对。

另:原始字节对(U+E000 系)在重定向文件名中的形态属不同载体域,本 PR 的门(仅 U+E400 在场才折)不触及,维持现状。

本 PR 删除了什么

无删除:净行数 +34(4 文件 +53/−19,其中测试文件为 inverted pin 断言改写与注释更新)。产品改动为两处边界折对 + 一个共享 helper + 两条 lint allowlist;未动 src/lexer/continuation.rs 与 docs/api-ledger.md,未改 #2881 解码器本体。

…cs golden

The diagnostics_carry_no_markers cell carried the command-not-found
and redirect-filename legs as inverted pins asserting the broken
E400-pair output. Assert the GNU form instead: the diagnostic names
the raw U+E314 char and the redirect creates the raw-char filename.
On the unfixed tree both legs fail (fail-first evidence in the lane
REPORT); the product fix follows in the next commit.

Refs #3040
… + redirect filename (Refs #3040)

A stored registry-zone char (e.g. $'\uE314') rides in transport
form as an E400 literal-char escape pair. Two use-as-a-name
boundaries never folded the pair back:

1. The command-not-found diagnostic: GNU execute_cmd.c:5909 runs
   printable_filename (general.c:1040) over the raw word, so the
   printed name is the raw char. printable_filename's unquoted
   branch now folds the pair through the same boundary decoder the
   argv/env crossings use (substitution_metadata::
   decode_raw_byte_markers_to_byte_chars, rubash#2881). This one
   function serves both diagnostic sites (external_inner,
   pipeline_stages).

2. The redirect target filename: GNU redir.c:298
   redirection_expand returns the string do_redirection_internal
   opens verbatim. redirect_operand_literal — where the operand is
   finalized as a filename — now folds the pair through the same
   decoder, and the failglob 'no match' diagnostic that names the
   operand folds identically. The redirect open-error diagnostic
   inherits the fix through the memoized target.

Both folds are gated on the escape introducer's presence, so
marker-free names and filenames are byte-untouched. The E7 lint
allowlist gains the two new contains: presence gates (117 consts /
260 sites, lint OK).

本 PR 删除了什么: nothing — no code removed; the change adds the
two boundary folds, the shared filename-fold helper, and two lint
allowlist lines.
@caomengxuan666
caomengxuan666 merged commit 8a28d35 into master Nov 8, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant