fix: systematic byte fidelity for config strings and RV7 gaps

Resolves the 9 gap groups in docs/rewrite/notes/review-rv7-codex.md and
audits every string-typed config field against its consumers
(field -> consumers -> decode status table in final-Z9.md):
- Windows EnvMap keys use a port of Zig's nls.zig uppercase table
  (upcaseW); Windows locale init follows Zig's chain (setlocale +
  _putenv_s); malformed WTF-8 now fails process launch conversions like
  Zig instead of substituting U+FFFD; kitty file paths convert WTF-8.
- bash --rcfile/--init-file, configured TERM and inherited GTK LANG
  keep their original bytes.
- C API clipboard completion and ghostty_surface_binding_action take
  bytes; complete_clipboard_request is byte-typed through the core.
- text:/csi:/esc: bindings, enquiry-response, input = path:, embedded
  initial_input, search needles, titles, link regexes, clipboard
  codepoint map, command palette text and GTK font/namespace values
  decode the escape encoding before use.

Remaining by design: D-Bus a{ss} values and +new-window arguments are
UTF-8 by D-Bus type. C API key/preedit text follows separately.

Test Plan:
- cargo test --workspace
- just check-macos (both), just check-windows, just check-wasm
This commit is contained in:
ddidderr committed 2026-10-12 10:50:20 +02:00
1 parent 1ff5db0527
commit e6564cb838
40 files changed
+986 -167

No files matched your search

+26
View File
@@ -516,6 +516,32 @@ fn selection_and_clipboard_round_trip() {
unsafe { ghostty_surface_free(s) };
}
/// A child that prints the hex of the first two bytes it receives raw.
const HEX_TWO: &str = "stty raw -echo; dd bs=1 count=2 2>/dev/null | od -An -tx1 | tr -d ' \\n'; printf '\\nHEX-DONE\\n'; sleep 5";
#[test]
fn clipboard_completion_and_binding_action_keep_raw_bytes() {
// Clipboard contents are bytes: 0xFF must reach the child as 0xFF.
let h = host!("");
let s = h.surface(HEX_TWO);
let act = b"paste_from_clipboard";
assert!(unsafe { ghostty_surface_binding_action(s, act.as_ptr().cast(), act.len()) });
let (_, state) = rec(|r| r.reads.last().copied()).expect("clipboard read");
let pasted = CString::new(&b"a\xff"[..]).unwrap();
unsafe {
ghostty_surface_complete_clipboard_request(s, pasted.as_ptr(), state as *mut c_void, false);
};
h.wait_screen(s, "61ff");
unsafe { ghostty_surface_free(s) };
// Binding action text is bytes too: `text:` followed by 0xFF.
let s = h.surface(HEX_TWO);
let act = b"text:b\xff";
assert!(unsafe { ghostty_surface_binding_action(s, act.as_ptr().cast(), act.len()) });
h.wait_screen(s, "62ff");
unsafe { ghostty_surface_free(s) };
}
#[test]
fn osc_52_and_title_and_pwd_actions() {
let h = host!("clipboard-write = allow\n");