diff --git a/fish-rust/src/fish_indent.rs b/fish-rust/src/fish_indent.rs index c8a36938d..8a4ee5cfc 100755 --- a/fish-rust/src/fish_indent.rs +++ b/fish-rust/src/fish_indent.rs @@ -521,11 +521,14 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> { // Unescape the string - this leaves special markers around if there are any // expansions or anything. We specifically tell it to not compute backslash-escapes // like \U or \x, because we want to leave them intact. - let mut unescaped = unescape_string( + let Some(mut unescaped) = unescape_string( input, UnescapeStringStyle::Script(UnescapeFlags::SPECIAL | UnescapeFlags::NO_BACKSLASHES), - ) - .unwrap(); + // TODO: If we cannot unescape that means there's something fishy, + // like a NUL in the source. + ) else { + return input.into(); + }; // Remove INTERNAL_SEPARATOR because that's a quote. let quote = |ch| ch == INTERNAL_SEPARATOR; diff --git a/tests/checks/indent.fish b/tests/checks/indent.fish index 3f2f3d5f1..5368a93c8 100644 --- a/tests/checks/indent.fish +++ b/tests/checks/indent.fish @@ -443,3 +443,6 @@ echo a\<\) | $fish_indent # CHECK: a < ) echo b\|\{ | $fish_indent # CHECK: b | { + +echo "\'\\\\\x00\'" | string unescape | $fish_indent | string escape +# CHECK: \'\\\x00\'