mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
Fix parser panic (#5820)
This commit is contained in:
@ -159,6 +159,22 @@ pub fn parse_binary_with_invalid_octal_format() {
|
||||
assert!(!matches!(&expressions[0].expr, Expr::Binary(_)))
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn parse_binary_with_multi_byte_char() {
|
||||
let engine_state = EngineState::new();
|
||||
let mut working_set = StateWorkingSet::new(&engine_state);
|
||||
|
||||
// found using fuzzing, Rust can panic if you slice into this string
|
||||
let contents = b"0x[\xEF\xBF\xBD]";
|
||||
let (block, err) = parse(&mut working_set, None, contents, true, &[]);
|
||||
|
||||
assert!(err.is_none());
|
||||
assert!(block.len() == 1);
|
||||
let expressions = &block[0];
|
||||
assert!(expressions.len() == 1);
|
||||
assert!(!matches!(&expressions[0].expr, Expr::Binary(_)))
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn parse_string() {
|
||||
let engine_state = EngineState::new();
|
||||
|
Reference in New Issue
Block a user