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:
1 parent
ffc91c31e4
commit
af094276f8
40 files changed
+986
-167
No files matched your search
@@ -326,7 +326,10 @@ impl Harness {
|
||||
.get(&cb_key(clipboard))
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
match self.surface.complete_clipboard_request(req, &text, false) {
|
||||
match self
|
||||
.surface
|
||||
.complete_clipboard_request(req, text.as_bytes(), false)
|
||||
{
|
||||
Ok(()) => {}
|
||||
Err(ClipboardError::UnsafePaste | ClipboardError::UnauthorizedPaste) => {
|
||||
self.rt
|
||||
|
||||
@@ -111,7 +111,7 @@ fn unbracketed_paste_converts_newlines_and_requires_confirmation_when_unsafe() {
|
||||
// Confirm it.
|
||||
let c = h.rt.confirmations.borrow()[0].clone();
|
||||
h.surface
|
||||
.complete_clipboard_request(c.request, &c.text, true)
|
||||
.complete_clipboard_request(c.request, c.text.as_bytes(), true)
|
||||
.unwrap();
|
||||
h.expect_input(b"rm -rf x\rls");
|
||||
}
|
||||
@@ -367,6 +367,31 @@ fn text_csi_esc_and_ignore_bindings() {
|
||||
h.expect_input(b"hi!\x1b[1;5H\x1bx");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_loaded_text_csi_esc_write_decoded_bytes() {
|
||||
use ghostty_os::osbytes::EncodedOs;
|
||||
|
||||
let h = harness!(Harness::recorder("", &[]));
|
||||
let enc = |raw: &[u8]| EncodedOs::from_bytes(raw).into_encoded();
|
||||
// Byte FF and a literal U+FDD0 must reach the pty unchanged, not as
|
||||
// the reversible escape encoding.
|
||||
for (kind, raw, want) in [
|
||||
("text", &b"a\xffb"[..], b"a\xffb".to_vec()),
|
||||
(
|
||||
"text",
|
||||
"\u{fdd0}".as_bytes(),
|
||||
"\u{fdd0}".as_bytes().to_vec(),
|
||||
),
|
||||
("csi", &b"\xff"[..], b"\x1b[\xff".to_vec()),
|
||||
("esc", "\u{fdd0}".as_bytes(), b"\x1b\xef\xb7\x90".to_vec()),
|
||||
] {
|
||||
h.mark();
|
||||
let a = ghostty_input::binding::Action::parse(&format!("{kind}:{}", enc(raw))).unwrap();
|
||||
assert!(h.surface.perform_binding_action(&a).unwrap());
|
||||
h.expect_input(&want);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csi_binding_longer_than_the_zig_buffer_is_rejected() {
|
||||
let h = harness!(Harness::recorder("", &[]));
|
||||
|
||||
@@ -162,7 +162,7 @@ fn osc52_write_ask_requires_confirmation_and_deny_ignores() {
|
||||
// The user confirms: the apprt calls complete_clipboard_request.
|
||||
let c = h.rt.confirmations.borrow()[0].clone();
|
||||
h.surface
|
||||
.complete_clipboard_request(c.request, &c.text, true)
|
||||
.complete_clipboard_request(c.request, c.text.as_bytes(), true)
|
||||
.unwrap();
|
||||
assert_eq!(h.rt.writes.borrow().len(), 2);
|
||||
|
||||
@@ -208,7 +208,7 @@ fn osc52_read_requires_confirmation_by_default() {
|
||||
assert_eq!(h.recorded(), Vec::<u8>::new());
|
||||
let c = h.rt.confirmations.borrow()[0].clone();
|
||||
h.surface
|
||||
.complete_clipboard_request(c.request, &c.text, true)
|
||||
.complete_clipboard_request(c.request, c.text.as_bytes(), true)
|
||||
.unwrap();
|
||||
// base64("secret") = c2VjcmV0
|
||||
h.expect_input(b"\x1b]52;c;c2VjcmV0\x1b\\");
|
||||
|
||||
Reference in new issue
Block a user