Skip to content

parser/executor: encode imported env entries at the entry face (Refs #3207) - #3233

Merged
caomengxuan666 merged 4 commits into
masterfrom
fix/3207-entry-encoding
Nov 10, 2026
Merged

caomengxuan666 merged 4 commits into
masterfrom
fix/3207-entry-encoding

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #3207

Summary

Entry-encoding contract gap (residual of the #3105 contract, following the #2884 env-import precedent): host-side raw values handed to SessionBuilder env seeds and to VariablesView::set / set_array / set_assoc landed in storage unencoded, so a carrier byte (0x1c) in a value was stripped as live protocol at finalization and a marker-zone character was read as live protocol downstream. Executor::set_env is deliberately not the encoding boundary: shell internals hand it cooked values, and encoding there would double-encode.

Mechanism

  • src/executor/env_helpers.rs: factor the per-name channel rule out of entry_encode_imported_env into a new pub(crate) helper entry_encode_imported_env_value(name, value) — __RUBASH_* names pass verbatim, BASH_FUNC_*%% names take the SOURCE encoding, every other value takes the DATA encoding. entry_encode_imported_env now maps through the helper; its behaviour is unchanged.
  • src/api/session.rs: the SessionBuilder build loop entry-encodes each env seed before set_env. The __RUBASH_SCRIPT_NAME argv0 line stays verbatim.
  • src/api/views.rs: VariablesView::set entry-encodes the scalar value; set_array / set_assoc entry-encode each cell value (the per-name rule keyed on the variable name).
  • Executor::set_env, src/lexer/continuation.rs, and docs/api-ledger.md are untouched: no new public face is added.

Pin

  • tests/issue3207_entry_encoding_residual.rs (7 cells, committed first, before the product change): builder seed finalization, builder seed export-to-child, builder seed marker-zone guard, VariablesView::set finalization, set_array finalization, set_assoc finalization, plain-value round-trip guard.
  • Fail-first on base 6ace5616: 2 passed / 5 failed — the five carrier-loss cells red with the same signature (stored f\x1cg read back as fc); the marker-zone and plain-value cells green as guards.

Verification (batch run B12, captain batch session, 2026-11-10)

  • Head pin issue3207_entry_encoding_residual: 7 passed / 0 failed, with a fresh pin-binary mtime as second evidence.
  • Lib bilateral: head 1206 passed / 0 failed / 4 ignored, failure name set empty; base 1205 passed / 1 failed / 4 ignored, the single base red being the pre-existing issue2875 cell; the head name set is a subset of the base set.
  • Neighbour stems: session_api 7/0, issue2884 15/0, issue3105 15/0, issue590 9/0 (the issue590 stem needs the windows-shim feature build so the bash shim binary exists on Linux; with that build all nine cells pass).
  • RUSTFLAGS="-D warnings" cargo check --locked --lib --bins rc=0; python3 scripts/check-marker-literals.py rc=0; cargo fmt --check rc=0.

本 PR 删除了什么

无产品代码删除。entry_encode_imported_env 原有的内联按名分支被抽出为共享 helper,原逻辑逐字保留在新 helper 中,属于行为不变的重构。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 10, 2026 04:12
@caomengxuan666
caomengxuan666 merged commit 7e5c7c0 into master Nov 10, 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