Skip to content

Commit

Permalink
Merge pull request #235 from eklmv/fix_scanner_wspaces
Browse files Browse the repository at this point in the history
fix(scanner): do not allow whitespaces in dollar quote tag
  • Loading branch information
matthias-Q authored Jan 3, 2024
2 parents c85ffb5 + fe2dd42 commit dfa2535
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ char* scan_dollar_string_tag(TSLexer *lexer) {
return NULL;
}

while (lexer->lookahead != '$' && !lexer->eof(lexer)) {
while (lexer->lookahead != '$' && !iswspace(lexer->lookahead) && !lexer->eof(lexer)) {
tag = add_char(tag, text_size, lexer->lookahead, ++index);
lexer->advance(lexer, false);
}
Expand Down
48 changes: 48 additions & 0 deletions test/corpus/errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,51 @@ $c$;
(UNEXPECTED 'c')
(UNEXPECTED ';'))
(MISSING dollar_quote)))))

================================================================================
Function body with a tag name contains whitespace
================================================================================

create or replace function public.do_stuff()
returns trigger
language plpgsql
as $a$
begin
return $b $text$b $;
end;
$a$;

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

(program
(statement
(create_function
(keyword_create)
(keyword_or)
(keyword_replace)
(keyword_function)
(object_reference
(identifier)
(identifier))
(function_arguments)
(keyword_returns)
(keyword_trigger)
(function_language
(keyword_language)
(identifier))
(function_body
(keyword_as)
(dollar_quote)
(keyword_begin)
(keyword_return)
(ERROR
(UNEXPECTED 'b'))
(field
(identifier))
(ERROR
(UNEXPECTED 't')
(keyword_text)
(UNEXPECTED 'b')
(UNEXPECTED ';'))
(keyword_end)
(dollar_quote)))))

0 comments on commit dfa2535

Please sign in to comment.