mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:37:46 +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
4 changed files with 36 additions and 7 deletions
|
@ -374,7 +374,11 @@ JS::Interpreter& Document::interpreter()
|
|||
|
||||
JS::Value Document::run_javascript(const StringView& source)
|
||||
{
|
||||
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 JS::js_undefined();
|
||||
}
|
||||
dbg() << "Document::run_javascript('" << source << "') will run:";
|
||||
program->dump(0);
|
||||
return document().interpreter().run(*program);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue