mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 10:37:34 +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
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))
|
if (!match(TokenType::TemplateLiteralString))
|
||||||
append_empty_string();
|
append_empty_string();
|
||||||
|
|
||||||
while (!match(TokenType::TemplateLiteralEnd) && !match(TokenType::UnterminatedTemplateLiteral)) {
|
while (!done() && !match(TokenType::TemplateLiteralEnd) && !match(TokenType::UnterminatedTemplateLiteral)) {
|
||||||
if (match(TokenType::TemplateLiteralString)) {
|
if (match(TokenType::TemplateLiteralString)) {
|
||||||
auto token = consume();
|
auto token = consume();
|
||||||
expressions.append(parse_string_literal(token));
|
expressions.append(parse_string_literal(token));
|
||||||
|
@ -741,6 +741,9 @@ NonnullRefPtr<TemplateLiteral> Parser::parse_template_literal(bool is_tagged)
|
||||||
|
|
||||||
if (!match(TokenType::TemplateLiteralString))
|
if (!match(TokenType::TemplateLiteralString))
|
||||||
append_empty_string();
|
append_empty_string();
|
||||||
|
} else {
|
||||||
|
expected("Template literal string or expression");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue