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
@@ -100,7 +100,9 @@ fn run_args(
|
||||
continue;
|
||||
}
|
||||
if FIELDS.contains(&d.key.as_str()) {
|
||||
writeln!(stderr, "config error: {d}")?;
|
||||
stderr.write_all(&ghostty_os::osbytes::config_str_to_bytes(&format!(
|
||||
"config error: {d}\n"
|
||||
)))?;
|
||||
exit = true;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +135,9 @@ fn run_args(
|
||||
{
|
||||
continue;
|
||||
}
|
||||
writeln!(stderr, "config error: {d}")?;
|
||||
stderr.write_all(&ghostty_os::osbytes::config_str_to_bytes(&format!(
|
||||
"config error: {d}\n"
|
||||
)))?;
|
||||
}
|
||||
|
||||
let font_grid_set = match SharedGridSet::new() {
|
||||
|
||||
@@ -53,7 +53,11 @@ fn run_inner(opts: &Options, stdout: &mut dyn Write) -> Result<u8, Error> {
|
||||
|
||||
if !cfg.diagnostics.items().is_empty() {
|
||||
for diag in cfg.diagnostics.items() {
|
||||
writeln!(stdout, "{diag}")?;
|
||||
// Diagnostics embed config values in the reversible byte
|
||||
// encoding; print the original bytes.
|
||||
stdout.write_all(&ghostty_os::osbytes::config_str_to_bytes(&format!(
|
||||
"{diag}\n"
|
||||
)))?;
|
||||
}
|
||||
return Ok(1);
|
||||
}
|
||||
@@ -105,6 +109,27 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn diagnostics_print_original_bytes() {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let path = tmp.path().join("config");
|
||||
std::fs::write(&path, b"bad\xffkey = 1\n").unwrap();
|
||||
let opts = Options {
|
||||
config_file: Some(path.to_string_lossy().into_owned()),
|
||||
};
|
||||
let mut out = Vec::new();
|
||||
assert_eq!(1, run_inner(&opts, &mut out).unwrap());
|
||||
assert!(
|
||||
out.windows(7).any(|w| w == b"bad\xffkey"),
|
||||
"{:?}",
|
||||
String::from_utf8_lossy(&out)
|
||||
);
|
||||
assert!(!out.contains(&0xef), "no escape encoding in the output");
|
||||
let _ = path.as_os_str().as_bytes();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validate_missing_file_is_error() {
|
||||
let opts = Options {
|
||||
|
||||
Reference in new issue
Block a user