This commit is contained in:
Jakob Hellermann 2026-06-02 08:18:41 +00:00 committed by GitHub
commit 39bc0a7693
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 5 deletions

View File

@ -1126,7 +1126,7 @@ plugins {
welcome_screen true welcome_screen true
} }
filepicker location="zellij:strider" { filepicker location="zellij:strider" {
cwd "\/" cwd "/"
} }
} }
mouse_mode false mouse_mode false

View File

@ -334,10 +334,6 @@ impl KdlEntry {
// It's already a v1 string // It's already a v1 string
s s
} }
} else if !s.starts_with("r#") {
// `/` is an escaped char in v2
let s = s.replace("\\/", "/"); // Maneuvering. Will fix in a sec.
s.replace('/', "\\/")
} else { } else {
// We're all good! Let's move on. // We're all good! Let's move on.
s.to_string() s.to_string()

View File

@ -24,3 +24,34 @@ fn build_and_format() {
"# "#
); );
} }
#[test]
#[cfg(feature = "v1")]
fn ensure_v1_does_not_over_escape_forward_slash() {
// Per the v1 spec, `\/` is a permitted escape but unescaped `/` is also
// legal. ensure_v1 should not introduce unnecessary `\/` escapes.
let input = "node \"a/b/c\"\n";
let mut doc = KdlDocument::parse_v1(input).unwrap();
doc.ensure_v1();
assert_eq!(doc.to_string(), input);
}
#[test]
#[cfg(feature = "v1")]
fn ensure_v2_strips_escaped_forward_slash() {
// `\/` is forbidden in v2, so ensure_v2 must convert it to a `/`.
let input = "node \"a\\/b\"\n";
let mut doc = KdlDocument::parse_v1(input).unwrap();
doc.ensure_v2();
assert_eq!(doc.to_string(), "node \"a/b\"\n");
}
#[test]
#[cfg(feature = "v1")]
fn ensure_v1_preserves_raw_string_with_backslash_slash() {
// In a raw string, `\/` is two literal characters, and should be kept as is.
let input = "node r#\"a\\/b\"#\n";
let mut doc = KdlDocument::parse_v1(input).unwrap();
doc.ensure_v1();
assert_eq!(doc.to_string(), input);
}