mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
LibJS: Fix Parser.parse_template_literal looping forever
parse_template_literal now breaks out of the loop if it sees something it doesn't expect. Additionally, it now checks for EOFs.
This commit is contained in:
parent
a586a84450
commit
5046f15824
Notes:
sideshowbarker
2024-07-19 05:51:24 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/5046f15824e Pull-request: https://github.com/SerenityOS/serenity/pull/2490 Reviewed-by: https://github.com/sunverwerth
1 changed files with 4 additions and 1 deletions
|
@ -719,7 +719,7 @@ NonnullRefPtr<TemplateLiteral> Parser::parse_template_literal(bool is_tagged)
|
|||
if (!match(TokenType::TemplateLiteralString))
|
||||
append_empty_string();
|
||||
|
||||
while (!match(TokenType::TemplateLiteralEnd) && !match(TokenType::UnterminatedTemplateLiteral)) {
|
||||
while (!done() && !match(TokenType::TemplateLiteralEnd) && !match(TokenType::UnterminatedTemplateLiteral)) {
|
||||
if (match(TokenType::TemplateLiteralString)) {
|
||||
auto token = consume();
|
||||
expressions.append(parse_string_literal(token));
|
||||
|
@ -741,6 +741,9 @@ NonnullRefPtr<TemplateLiteral> Parser::parse_template_literal(bool is_tagged)
|
|||
|
||||
if (!match(TokenType::TemplateLiteralString))
|
||||
append_empty_string();
|
||||
} else {
|
||||
expected("Template literal string or expression");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue