mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 13:23:09 +00:00
fish_indent: Fix crash with NUL in the source
Really we should *reject* this
This commit is contained in:
parent
52a3e1393f
commit
50acc4f4de
2 changed files with 9 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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\'
|
||||
|
|
Loading…
Reference in a new issue