Repository navigation
fix(prompt): fold E400 literal-char pairs in the prompt transport decode (Refs #3038) - #3072
Merged
Merged
Conversation
…red U+E314 value
The $pua leg of prompts_via_public_api_carry_no_markers was an
inverted pin asserting the broken rendering "<\u{E400}\u{E314}>"
(the E400 literal-char pair surviving into the rendered prompt).
GNU renders the stored char verbatim: parse.y:6265
decode_prompt_string + parse.y:6689 expand_prompt_string insert the
stored value bytes as-is; there is no escape-pair layer between
storage and render.
Correct the leg to assert "<\u{E314}>" and add a gate-independence
leg: a value carrying both transports (E400 pair for the typed char,
raw-byte pair for an ESC byte) must render both raw.
Fail-first on base 4984ce5: the corrected cell fails with
left "<\u{e400}\u{e314}>" vs right "<\u{e314}>". Refs #3038
…ode (Refs #3038) decode_prompt_transport gated its decode on the raw-byte marker (U+E000) alone, so an expansion result whose only transport was an E400 literal-char pair — a stored registry-zone char such as $'\uE314', carried as E400+E314 by push_literal_char — was returned verbatim and the pair leaked into the rendered prompt. Whether the pair folded depended on an unrelated raw-byte pair happening to be present in the same prompt. GNU has no escape-pair layer between storage and prompt render: parse.y:6689 expand_prompt_string(result, Q_DOUBLE_QUOTES, 0) inserts the stored value bytes verbatim, and the CTLESC protection of parse.y:5694-5706 is token-internal, removed by subst.c:4692 dequote_escapes before any boundary. Fix the gate, not the decoder: decode_raw_byte_markers already folds E400+c to c; open the gate on either transport family. All four callers of decode_prompt_transport are terminal-bound prompt render channels (expand_prompt_string{,_mut}, xtrace_prefix for PS4, read -p display); the script-visible ${var@P} transform does not funnel through here and is unaffected.
caomengxuan666
marked this pull request as ready for review
November 8, 2026 04:11
This was referenced Nov 8, 2026
Closed
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.
UNVERIFIED-BY-CAPTAIN — 车道自报,待队长复核。
现象(Refs #3038)
经公开 API
Session::expand_prompt:pua=$'\uE314'后expand_prompt("<$pua>")返回"<\u{E400}\u{E314}>"——E400 字面对转义对漏进渲染后的提示串;GNU 渲染原始字符"<\u{E314}>"。根因
decode_prompt_transport(src/executor/prompt_expansion.rs)是提示通道的展开后传输解码,但它的存在性门只查原始字节标记族(U+E000 引导符)。展开结果只携带 E400 字面对(存储的注册区字符,如$'\uE314',经push_literal_char以 E400+E314 承载)时,门不开、解码不跑,整对原样漏出。也就是说:E400 对折不折,取决于同一提示串里是否恰好有无关的原始字节对在场——$esc/$tab等腿因同格其他内容或守卫消费者而通过,$pua单独出现时漏。解码器本体没有缺陷:
decode_raw_byte_markers本就无条件折叠 E400+c。缺的是门。GNU 锚点
parse.y:6265 decode_prompt_string+parse.y:6689:展开通道以expand_prompt_string(result, Q_DOUBLE_QUOTES, 0)把存储值字节逐字插入提示串——GNU 在存储与渲染之间没有转义对层。parse.y:5694-5706:CTLESC 保护纯属 token 内部机制;subst.c:4692 dequote_escapes在任何边界之前去除。rubash 的 E400 对是同一内部传输,渲染边界必须同样折叠。pua=$'\uE314'; printf '<%s>\n' "$pua"输出字节3c ee 8c 94 3e 0a——原始字符逐字出。修法(按机制,一处门 + 一个 markers 助手)
markers.rs新增contains_decodable_transport:同时覆盖解码器折叠的两个传输族(原始字节对 + E400 字面对)的存在性门——检查本身不做任何变换,命中才路由进 pair-aware 解码器。decode_prompt_transport改走该门,并更新其文档注释说明 E400 半边与本单来历。prompt_expansion.rs时被 lint 判为未审contains站点,按 lint 指引改为经markers.rs助手路由(未加 allowlist 条目);旧门行对应的 allowlist 条目随之 stale,按 lint 要求删除一行(站点数 258 → 257)。decode_prompt_transport的四个调用点全是终端向提示渲染通道(expand_prompt_string{,_mut}、PS4 的xtrace_prefix、read -p显示);脚本可见的${var@P}变换不经此漏斗,不受影响。本 PR 不动解码器本体、不动其他调用面逻辑。回归钉
tests/marker_leak_golden.rs的prompts_via_public_api_carry_no_markers格:"<\u{E400}\u{E314}>"),现改回正确断言"<\u{E314}>"。4984ce5c,仅改断言未修码):该格按预期翻红,left: "<\u{e400}\u{e314}>"vsright: "<\u{e314}>",与 issue 正文逐字一致。车道自报验证(基底 4984ce5,构建走 build-slot + scrubbed_cargo)
marker_leak_golden_pty:2 passed / 0 failed。RUSTFLAGS="-D warnings"编译 golden 目标:净。--checkrc=0;hygiene rc=0;改动文件 CR 零。本 PR 删除了什么
scripts/marker-lint-allowlist.txt中旧门行的一行 stale 条目(contains:RAW_BYTE_MARKER_ESCAPE@ prompt_expansion.rs)——该站点已被 markers 助手取代,条目不再匹配任何代码。净行数:+39 / −11(净 +28)。
队长复核项
7b32ac82的 tests 改动移到基底树,prompts_via_public_api_carry_no_markers应以 left"<\u{e400}\u{e314}>"翻红。$'\uE314'值经 PS4 前缀与read -p "$pua"显示应同样渲染原始字符(车道未单独钉这两条通道,格覆盖在 golden 的 PS4 格与 PTY read_p 格的既有形状内)。