mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-14 14:03:58 +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
|
// Unescape the string - this leaves special markers around if there are any
|
||||||
// expansions or anything. We specifically tell it to not compute backslash-escapes
|
// expansions or anything. We specifically tell it to not compute backslash-escapes
|
||||||
// like \U or \x, because we want to leave them intact.
|
// like \U or \x, because we want to leave them intact.
|
||||||
let mut unescaped = unescape_string(
|
let Some(mut unescaped) = unescape_string(
|
||||||
input,
|
input,
|
||||||
UnescapeStringStyle::Script(UnescapeFlags::SPECIAL | UnescapeFlags::NO_BACKSLASHES),
|
UnescapeStringStyle::Script(UnescapeFlags::SPECIAL | UnescapeFlags::NO_BACKSLASHES),
|
||||||
)
|
// TODO: If we cannot unescape that means there's something fishy,
|
||||||
.unwrap();
|
// like a NUL in the source.
|
||||||
|
) else {
|
||||||
|
return input.into();
|
||||||
|
};
|
||||||
|
|
||||||
// Remove INTERNAL_SEPARATOR because that's a quote.
|
// Remove INTERNAL_SEPARATOR because that's a quote.
|
||||||
let quote = |ch| ch == INTERNAL_SEPARATOR;
|
let quote = |ch| ch == INTERNAL_SEPARATOR;
|
||||||
|
|
|
@ -443,3 +443,6 @@ echo a\<\) | $fish_indent
|
||||||
# CHECK: a < )
|
# CHECK: a < )
|
||||||
echo b\|\{ | $fish_indent
|
echo b\|\{ | $fish_indent
|
||||||
# CHECK: b | {
|
# CHECK: b | {
|
||||||
|
|
||||||
|
echo "\'\\\\\x00\'" | string unescape | $fish_indent | string escape
|
||||||
|
# CHECK: \'\\\x00\'
|
||||||
|
|
Loading…
Reference in a new issue