fish_indent: Fix crash with NUL in the source

Really we should *reject* this
This commit is contained in:
Fabian Boehm
2024-01-10 20:47:39 +01:00
parent 52a3e1393f
commit 50acc4f4de
2 changed files with 9 additions and 3 deletions

View File

@@ -521,11 +521,14 @@ fn clean_text(&self, input: &wstr) -> WString {
// 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;