Skip to content

Commit

Permalink
fix: do not parse strings inside a REGEX_NO_SPACE
Browse files Browse the repository at this point in the history
  • Loading branch information
amaanq committed Aug 28, 2023
1 parent 7e7187d commit 94ae7b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ static bool scan(Scanner *scanner, TSLexer *lexer, const bool *valid_symbols) {
if (!lexer->eof(lexer)) {
advance(lexer);
}
} else if (lexer->lookahead == '"') {
return false;
} else {
if (iswspace(lexer->lookahead)) {
lexer->mark_end(lexer);
Expand Down
19 changes: 18 additions & 1 deletion test/corpus/statements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,7 @@ Test commands with regexes
[[ ${var1} == *${var2}* ]]
[[ "$server" =~ [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3} ]]
[[ "$primary_wins" =~ ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) ]]
[[ -f ${x} && $(od -t x1 -N 4 "${x}") == *"7f 45 4c 46"* ]]

--------------------------------------------------------------------------------

Expand Down Expand Up @@ -1086,7 +1087,23 @@ Test commands with regexes
(string
(simple_expansion
(variable_name)))
(regex))))
(regex)))
(test_command
(unary_expression
(test_operator)
(binary_expression
(binary_expression
(expansion
(variable_name))
(command_substitution
(command
(command_name (word))
(word)
(word)
(word)
(number)
(string (expansion (variable_name))))))
(concatenation (word) (string) (word))))))

================================================================================
Subshells
Expand Down

0 comments on commit 94ae7b8

Please sign in to comment.