Skip to content

fix: PUA 码点 U+E401 与内部 marker 冲突 (#735) - #791

Merged
arookieofc merged 1 commit into
masterfrom
fix/735-pua-marker-collision
Oct 18, 2026
Merged

arookieofc merged 1 commit into
masterfrom
fix/735-pua-marker-collision

Conversation

@arookieofc

Copy link
Copy Markdown
Member

Closes #735

缺陷 1:$'\uE401' 被静默吞掉

ANSI_C_IFS_GUARD(U+E401)落在 marker zone(E000..E3FF)之外,又没进注册表——push_literal_char 不转义它,之后被 guard strip 当成内部 marker 吃掉了。

缺陷 2:${#var} 计数错误

parameter_char_length 只在含 E000 时解码,把转义引导 E400 本身也数进去了。

改动

  • src/executor/markers.rs:MARKER_ZONE_LAST 扩到 0xE401;新增 E400-aware 的 guard helper(strip_ansi_c_ifs_guard_cow、ansi_c_ifs_guard_to_ifs_glue 等)。
  • 8 处 guard strip / 转 IFS_GLUE 的地方改用 E400-aware helper(分布在 expand_braced_indices.rs、assignment_expansion.rs、command_prepare.rs、command_words.rs、conditional.rs、expand_word.rs)。

验证

修复后与 GNU bash 逐字节一致;新回归测试 tests/issue735_pua_marker_collision.rs 5/5 通过。

遗留(超出 scope)

read 读入 U+E401 输出为空;脚本源码字面量 U+E401(非 $'\u..." 形式)仍被吞——lexer 字面量路径从不调 push_literal_char(约 20 处拷贝点),建议另开 issue 跟踪。

@github-actions

Copy link
Copy Markdown
Contributor

欢迎!这是你的第一个 PR 🎉 请确认已跑过本地测试套件;CI 通过后维护者会 review。

@arookieofc
arookieofc merged commit 8bcc976 into master Oct 18, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/735-pua-marker-collision branch October 18, 2026 09:29
caomengxuan666 added a commit that referenced this pull request Oct 18, 2026
…d splice (#796)

v2=$'p\nq'$(echo r)s stored 6 characters where GNU bash 5.3.0
stores 5 (p newline q r s): one ANSI_C_IFS_GUARD byte reached the
cell. #791 extended the marker zone to cover U+E401 (rubash#735),
which re-routes the guard through the mixed command-substitution
splice's payload re-encoding: the bare guard crosses
append_expanded_shell_text and materializes as an E400-escaped pair,
and the assignment funnel's tail strip must then PRESERVE that pair
as #735 user data - so the transport carrier survived into storage.

The guard is field-split transport (rubash#379), and an assignment
value never field-splits, so the boundary that drops it is the
fragment boundary BEFORE the payload splice. Strip the bare guard
from the prefix and suffix fragments of
expand_mixed_command_substitution_assignment.

Differential pins (tests/issue379_ansic_blank_between_comsubs_
regressions.rs::assignment_comsub_fragments_store_clean_values,
byte-verified against the WSL GNU 5.3.0(1)-release oracle): prefix,
suffix and both-adjacent fragments store clean lengths 5/4/5, and the
for-list face keeps the decoded newline literal while field-splitting
only the substitution output.
caomengxuan666 added a commit that referenced this pull request Oct 18, 2026
…d splice (#796)

v2=$'p\nq'$(echo r)s stored 6 characters where GNU bash 5.3.0
stores 5 (p newline q r s): one ANSI_C_IFS_GUARD byte reached the
cell. #791 extended the marker zone to cover U+E401 (rubash#735),
which re-routes the guard through the mixed command-substitution
splice's payload re-encoding: the bare guard crosses
append_expanded_shell_text and materializes as an E400-escaped pair,
and the assignment funnel's tail strip must then PRESERVE that pair
as #735 user data - so the transport carrier survived into storage.

The guard is field-split transport (rubash#379), and an assignment
value never field-splits, so the boundary that drops it is the
fragment boundary BEFORE the payload splice. Strip the bare guard
from the prefix and suffix fragments of
expand_mixed_command_substitution_assignment.

Differential pins (tests/issue379_ansic_blank_between_comsubs_
regressions.rs::assignment_comsub_fragments_store_clean_values,
byte-verified against the WSL GNU 5.3.0(1)-release oracle): prefix,
suffix and both-adjacent fragments store clean lengths 5/4/5, and the
for-list face keeps the decoded newline literal while field-splitting
only the substitution output.
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.

user-typed PUA codepoints collide with the marker registry: ANSI-C E401 is silently swallowed (data loss); E301/E314 miscount as length 2

1 participant