Add an alias denylist for expansions (#4871)

This commit is contained in:
JT
2022-03-19 08:03:57 +13:00
committed by GitHub
parent 5a1af4d661
commit 983d115bc0
18 changed files with 516 additions and 159 deletions

View File

@ -31,7 +31,7 @@ pub fn evaluate_commands(
(commands.item.as_bytes(), commands.span.start)
};
let (output, err) = parse(&mut working_set, None, input, false);
let (output, err) = parse(&mut working_set, None, input, false, &[]);
if let Some(err) = err {
report_error(&working_set, &err);

View File

@ -206,7 +206,13 @@ impl NuCompleter {
let mut line = line.to_string();
line.insert(pos, 'a');
let pos = offset + pos;
let (output, _err) = parse(&mut working_set, Some("completer"), line.as_bytes(), false);
let (output, _err) = parse(
&mut working_set,
Some("completer"),
line.as_bytes(),
false,
&[],
);
for pipeline in output.pipelines.into_iter() {
for expr in pipeline.expressions {

View File

@ -36,7 +36,7 @@ pub fn evaluate_file(
let mut working_set = StateWorkingSet::new(engine_state);
trace!("parsing file: {}", path);
let _ = parse(&mut working_set, Some(&path), &file, false);
let _ = parse(&mut working_set, Some(&path), &file, false, &[]);
if working_set.find_decl(b"main").is_some() {
let args = format!("main {}", args.join(" "));

View File

@ -104,7 +104,7 @@ fn get_prompt_string(
}
Value::String { val: source, .. } => {
let mut working_set = StateWorkingSet::new(engine_state);
let (block, _) = parse(&mut working_set, None, source.as_bytes(), true);
let (block, _) = parse(&mut working_set, None, source.as_bytes(), true, &[]);
// Use eval_subexpression to force a redirection of output, so we can use everything in prompt
let ret_val = eval_subexpression(
engine_state,

View File

@ -17,7 +17,7 @@ impl Highlighter for NuHighlighter {
let (shapes, global_span_offset) = {
let mut working_set = StateWorkingSet::new(&self.engine_state);
let (block, _) = parse(&mut working_set, None, line.as_bytes(), false);
let (block, _) = parse(&mut working_set, None, line.as_bytes(), false, &[]);
let shapes = flatten_block(&working_set, &block);
(shapes, self.engine_state.next_span_start())

View File

@ -287,6 +287,7 @@ pub fn eval_source(
Some(fname), // format!("entry #{}", entry_num)
source,
false,
&[],
);
if let Some(err) = err {
report_error(&working_set, &err);

View File

@ -9,7 +9,7 @@ pub struct NuValidator {
impl Validator for NuValidator {
fn validate(&self, line: &str) -> ValidationResult {
let mut working_set = StateWorkingSet::new(&self.engine_state);
let (_, err) = parse(&mut working_set, None, line.as_bytes(), false);
let (_, err) = parse(&mut working_set, None, line.as_bytes(), false, &[]);
if matches!(err, Some(ParseError::UnexpectedEof(..))) {
ValidationResult::Incomplete