Title: [212118] branches/safari-603-branch

Diff

Modified: branches/safari-603-branch/LayoutTests/ChangeLog (212117 => 212118)


--- branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-10 17:31:37 UTC (rev 212117)
+++ branches/safari-603-branch/LayoutTests/ChangeLog	2017-02-10 17:33:28 UTC (rev 212118)
@@ -1,5 +1,22 @@
 2017-02-10  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r212026. rdar://problem/30096323
+
+    2017-02-09  Chris Dumez  <cdu...@apple.com>
+
+            Crash under FormSubmission::create()
+            https://bugs.webkit.org/show_bug.cgi?id=167200
+            <rdar://problem/30096323>
+
+            Reviewed by Darin Adler.
+
+            Add layout test coverage.
+
+            * fast/forms/formsubmission-appendFormData-crash-expected.txt: Added.
+            * fast/forms/formsubmission-appendFormData-crash.html: Added.
+
+2017-02-10  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211495. rdar://problem/30106362
 
     2017-02-01  Jer Noble  <jer.no...@apple.com>

Added: branches/safari-603-branch/LayoutTests/fast/forms/formsubmission-appendFormData-crash-expected.txt (0 => 212118)


--- branches/safari-603-branch/LayoutTests/fast/forms/formsubmission-appendFormData-crash-expected.txt	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/forms/formsubmission-appendFormData-crash-expected.txt	2017-02-10 17:33:28 UTC (rev 212118)
@@ -0,0 +1,3 @@
+This test passes if it does not crash.
+
+ a  

Added: branches/safari-603-branch/LayoutTests/fast/forms/formsubmission-appendFormData-crash.html (0 => 212118)


--- branches/safari-603-branch/LayoutTests/fast/forms/formsubmission-appendFormData-crash.html	                        (rev 0)
+++ branches/safari-603-branch/LayoutTests/fast/forms/formsubmission-appendFormData-crash.html	2017-02-10 17:33:28 UTC (rev 212118)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+function runTest() {
+    object.name = "foo";
+    input.autofocus = true;
+    output.appendChild(input);
+    form.submit();
+    setTimeout(function() {
+    if (window.testRunner)
+        testRunner.notifyDone();
+    }, 0);
+}
+
+function focushandler() {
+    for(var i = 0; i < 100; i++) {
+        var e = document.createElement("input");
+        form.appendChild(e);
+    }
+}
+</script>
+<body _onload_="runTest()">
+    <p>This test passes if it does not crash.</p>
+    <form id="form">
+    <object id="object">
+    <output id="output">a</output>
+    <input id="input" _onfocus_="focushandler()">
+</body>
+</html>

Modified: branches/safari-603-branch/Source/WebCore/ChangeLog (212117 => 212118)


--- branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-10 17:31:37 UTC (rev 212117)
+++ branches/safari-603-branch/Source/WebCore/ChangeLog	2017-02-10 17:33:28 UTC (rev 212118)
@@ -1,5 +1,39 @@
 2017-02-10  Matthew Hanson  <matthew_han...@apple.com>
 
+        Merge r212026. rdar://problem/30096323
+
+    2017-02-09  Chris Dumez  <cdu...@apple.com>
+
+            Crash under FormSubmission::create()
+            https://bugs.webkit.org/show_bug.cgi?id=167200
+            <rdar://problem/30096323>
+
+            Reviewed by Darin Adler.
+
+            The issue is that FormSubmission::create() was iterating over
+            form.associatedElements() as was calling Element::appendFormData()
+            in the loop. HTMLObjectElement::appendFormData() was calling
+            pluginWidget(PluginLoadingPolicy::Load) which causes a synchronous
+            layout and can fire events (such as focus event) synchronously.
+            Firing those events synchronously allows the JS to modify the
+            form.associatedElements() vector we are currently iterating on.
+
+            To avoid this issue, we now call pluginWidget(PluginLoadingPolicy::DoNotLoad)
+            in HTMLObjectElement::appendFormData() as we are not allowed to fire
+            synchronous events at this point. I also added a security assertion
+            in FormSubmission::create() to catch cases where we fire JS events
+            while iterating over the form associated elements to more easily
+            notice these things in the future.
+
+            Test: fast/forms/formsubmission-appendFormData-crash.html
+
+            * html/HTMLObjectElement.cpp:
+            (WebCore::HTMLObjectElement::appendFormData):
+            * loader/FormSubmission.cpp:
+            (WebCore::FormSubmission::create):
+
+2017-02-10  Matthew Hanson  <matthew_han...@apple.com>
+
         Merge r211495. rdar://problem/30106362
 
     2017-02-01  Jer Noble  <jer.no...@apple.com>

Modified: branches/safari-603-branch/Source/WebCore/html/HTMLObjectElement.cpp (212117 => 212118)


--- branches/safari-603-branch/Source/WebCore/html/HTMLObjectElement.cpp	2017-02-10 17:31:37 UTC (rev 212117)
+++ branches/safari-603-branch/Source/WebCore/html/HTMLObjectElement.cpp	2017-02-10 17:33:28 UTC (rev 212118)
@@ -509,7 +509,9 @@
     if (name().isEmpty())
         return false;
 
-    Widget* widget = pluginWidget();
+    // Use PluginLoadingPolicy::DoNotLoad here or it would fire JS events synchronously
+    // which would not be safe here.
+    auto* widget = pluginWidget(PluginLoadingPolicy::DoNotLoad);
     if (!is<PluginViewBase>(widget))
         return false;
     String value;

Modified: branches/safari-603-branch/Source/WebCore/loader/FormSubmission.cpp (212117 => 212118)


--- branches/safari-603-branch/Source/WebCore/loader/FormSubmission.cpp	2017-02-10 17:31:37 UTC (rev 212117)
+++ branches/safari-603-branch/Source/WebCore/loader/FormSubmission.cpp	2017-02-10 17:33:28 UTC (rev 212118)
@@ -1,4 +1,4 @@
-/*
+*
  * Copyright (C) 2010 Google Inc. All rights reserved.
  * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
  *
@@ -47,6 +47,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "NoEventDispatchAssertion.h"
 #include "TextEncoding.h"
 #include <wtf/CurrentTime.h>
 
@@ -204,18 +205,23 @@
     Vector<std::pair<String, String>> formValues;
 
     bool containsPasswordData = false;
-    for (auto& control : form->associatedElements()) {
-        HTMLElement& element = control->asHTMLElement();
-        if (!element.isDisabledFormControl())
-            control->appendFormData(*domFormData, isMultiPartForm);
-        if (is<HTMLInputElement>(element)) {
-            HTMLInputElement& input = downcast<HTMLInputElement>(element);
-            if (input.isTextField()) {
-                formValues.append(std::pair<String, String>(input.name().string(), input.value()));
-                input.addSearchResult();
+    {
+        NoEventDispatchAssertion noEventDispatchAssertion;
+
+        for (auto& control : form->associatedElements()) {
+            auto& element = control->asHTMLElement();
+            if (!element.isDisabledFormControl())
+                control->appendFormData(*domFormData, isMultiPartForm);
+            if (is<HTMLInputElement>(element)) {
+                auto& input = downcast<HTMLInputElement>(element);
+                if (input.isTextField()) {
+                    // formValues.append({ input.name().string(), input.value() });
+                    formValues.append(std::pair<String, String>(input.name().string(), input.value()));
+                    input.addSearchResult();
+                }
+                if (input.isPasswordField() && !input.value().isEmpty())
+                    containsPasswordData = true;
             }
-            if (input.isPasswordField() && !input.value().isEmpty())
-                containsPasswordData = true;
         }
     }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to