Repository navigation
fix(echo): encode non-scalar \u/\U escapes as numeric UTF-8 (Refs #3787) - #3793
Merged
Merged
Conversation
caomengxuan666
force-pushed
the
fix/3787-echo-nonscalar-escapes
branch
from
November 16, 2026 14:35
f7f20e6 to
7a1a4b8
Compare
Member
Author
|
【Y3-AUDIT】续作记录(第1轮进行中)
|
Member
Author
|
【Y3-AUDIT】PR #3793 第1轮 — 建议:PASS(含本轮续作提交 a0c603c) 机制核查:
腿:
F 点(原 head 的 CI 红,已续作消除):
续作记录:
未跑/VOID 的腿:独立 base fail-first 构建(diff 语义构造性等价,base 旧码必然产不出钉断言字节);macOS 实机复跑(修复逻辑为候选名探测,CI 重跑中) |
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.
根因
echo -e的\\u/\\U转换(src/builtins/echo.rspush_codepoint)用char::from_u32解码,代理区 U+D800–U+DFFF 与大于 U+10FFFF 的值返回None,转义被静默丢弃。GNU 经
builtins/echo.def→lib/sh/strtrans.c:161-181(ansicstr)→lib/sh/unicode.c:239u32cconv→unicode.c:154u32toutf8:UTF-8 locale 下按数值原样编码,不做标量校验——代理区为 3 字节 CESU-8(如 U+D800 →ED A0 80,源码注释明言可返回 0 但实际编码),U+110000 为 4 字节形(F4 90 80 80),至 < 0x80000000 为 5/6 字节形;≥ 0x80000000 转换产零字节(各 locale 均丢弃)。C locale 下u32tocesc回退保留转义原样(≥ 0x80000000 段除外)。修法
push_codepoint改为数值 UTF-8 编码(u32toutf8长度表的字节级移植,不做标量校验),并把 ≥ 0x80000000 的丢弃置于 locale 门之前(与lexer/ansi.rs#1465 同款先例);C locale 原样保留转义的门不变。$'...'与printf %b已与 GNU 一致,不动。回归钉
tests/issue3787_echo_e_nonscalar_escapes.rs:19 行 od 对账,覆盖 issue 16 探针形态(孤代理高/低位、成对、边界 U+D800/U+DC00/U+DBFF/U+DFFF、\\U0000D800形、U+110000)+ 合法标量/C locale/printf %b对照 + 同机制段(5 字节 U+200000、≥ 0x80000000 各 locale 丢弃)。src/builtins/echo.rs单元钉:UTF-8 locale 下 CESU-8/U+110000 编码、≥ 0x80000000 各 locale 丢弃。验证(UNVERIFIED-BY-CAPTAIN)
本 PR 删除了什么
无删除。仅
src/builtins/echo.rs的push_codepoint行为变更 + 新增回归钉。UNVERIFIED-BY-CAPTAIN