浏览代码

LibWeb: Don't attempt to run unparsed scripts

Andreas Kling 3 年之前
父节点
当前提交
e215580147
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp

+ 6 - 0
Userland/Libraries/LibWeb/HTML/Scripting/ClassicScript.cpp

@@ -59,6 +59,12 @@ NonnullRefPtr<ClassicScript> ClassicScript::create(String filename, StringView s
 // https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script
 // https://html.spec.whatwg.org/multipage/webappapis.html#run-a-classic-script
 JS::Value ClassicScript::run(RethrowErrors rethrow_errors)
 JS::Value ClassicScript::run(RethrowErrors rethrow_errors)
 {
 {
+    if (!m_script_record) {
+        // FIXME: Throw a SyntaxError per the spec.
+        dbgln("ClassicScript: Unable to run script {}", filename());
+        return {};
+    }
+
     dbgln("ClassicScript: Running script {}", filename());
     dbgln("ClassicScript: Running script {}", filename());
     (void)rethrow_errors;
     (void)rethrow_errors;