mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibJS: Do not execute scripts with parse errors
This adds missing checks in several LibJS consumers.
This commit is contained in:
parent
50b6b6ef86
commit
984c290ec0
Notes:
sideshowbarker
2024-07-19 07:38:28 +09:00
Author: https://github.com/sunverwerth
Commit: 984c290ec0
Pull-request: https://github.com/SerenityOS/serenity/pull/1775
4 changed files with 36 additions and 7 deletions
|
@ -59,7 +59,11 @@ void HTMLScriptElement::children_changed()
|
|||
if (source.is_empty())
|
||||
return;
|
||||
|
||||
auto program = JS::Parser(JS::Lexer(source)).parse_program();
|
||||
auto parser = JS::Parser(JS::Lexer(source));
|
||||
auto program = parser.parse_program();
|
||||
if (parser.has_errors())
|
||||
return;
|
||||
|
||||
document().interpreter().run(*program);
|
||||
}
|
||||
|
||||
|
@ -90,7 +94,11 @@ void HTMLScriptElement::inserted_into(Node& new_parent)
|
|||
return;
|
||||
}
|
||||
|
||||
auto program = JS::Parser(JS::Lexer(source)).parse_program();
|
||||
auto parser = JS::Parser(JS::Lexer(source));
|
||||
auto program = parser.parse_program();
|
||||
if (parser.has_errors())
|
||||
return;
|
||||
|
||||
document().interpreter().run(*program);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue