mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:55:40 +02:00
Restrict strings beginning with quote should also ending with quote (#13131)
# Description Closes: #13010 It adds an additional check inside `parse_string`, and returns `unbalanced quote` if input string is unbalanced # User-Facing Changes After this pr, the following is no longer allowed: ```nushell ❯ "asdfasdf"asdfasdf Error: nu::parser::extra_token_after_closing_delimiter × Invaild characters after closing delimiter ╭─[entry #1:1:11] 1 │ "asdfasdf"asdfasdf · ────┬─── · ╰── invalid characters ╰──── help: Try removing them. ❯ 'asdfasd'adsfadf Error: nu::parser::extra_token_after_closing_delimiter × Invaild characters after closing delimiter ╭─[entry #2:1:10] 1 │ 'asdfasd'adsfadf · ───┬─── · ╰── invalid characters ╰──── help: Try removing them. ``` # Tests + Formatting Added 1 test
This commit is contained in:
@ -17,6 +17,13 @@ pub enum ParseError {
|
||||
#[diagnostic(code(nu::parser::extra_tokens), help("Try removing them."))]
|
||||
ExtraTokens(#[label = "extra tokens"] Span),
|
||||
|
||||
#[error("Invalid characters after closing delimiter")]
|
||||
#[diagnostic(
|
||||
code(nu::parser::extra_token_after_closing_delimiter),
|
||||
help("Try removing them.")
|
||||
)]
|
||||
ExtraTokensAfterClosingDelimiter(#[label = "invalid characters"] Span),
|
||||
|
||||
#[error("Extra positional argument.")]
|
||||
#[diagnostic(code(nu::parser::extra_positional), help("Usage: {0}"))]
|
||||
ExtraPositional(String, #[label = "extra positional argument"] Span),
|
||||
@ -577,6 +584,7 @@ impl ParseError {
|
||||
ParseError::LabeledErrorWithHelp { span: s, .. } => *s,
|
||||
ParseError::RedirectingBuiltinCommand(_, s, _) => *s,
|
||||
ParseError::UnexpectedSpreadArg(_, s) => *s,
|
||||
ParseError::ExtraTokensAfterClosingDelimiter(s) => *s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user