Title: [290249] trunk
Revision
290249
Author
[email protected]
Date
2022-02-21 10:07:18 -0800 (Mon, 21 Feb 2022)

Log Message

Null check parent node in outdentParagraph
https://bugs.webkit.org/show_bug.cgi?id=235914

Patch by Rob Buis <[email protected]> on 2022-02-21
Reviewed by Wenson Hsieh.

Source/WebCore:

Null check parent node of enclosing node in outdentParagraph.

Test: editing/execCommand/outdent-paragraph-crash.html

* editing/IndentOutdentCommand.cpp:
(WebCore::IndentOutdentCommand::outdentParagraph):

LayoutTests:

* editing/execCommand/outdent-paragraph-crash-expected.txt: Added.
* editing/execCommand/outdent-paragraph-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (290248 => 290249)


--- trunk/LayoutTests/ChangeLog	2022-02-21 17:56:12 UTC (rev 290248)
+++ trunk/LayoutTests/ChangeLog	2022-02-21 18:07:18 UTC (rev 290249)
@@ -1,3 +1,13 @@
+2022-02-21  Rob Buis  <[email protected]>
+
+        Null check parent node in outdentParagraph
+        https://bugs.webkit.org/show_bug.cgi?id=235914
+
+        Reviewed by Wenson Hsieh.
+
+        * editing/execCommand/outdent-paragraph-crash-expected.txt: Added.
+        * editing/execCommand/outdent-paragraph-crash.html: Added.
+
 2022-02-21  Tyler Wilcock  <[email protected]>
 
         AX: Add test for r290130 (https://trac.webkit.org/changeset/290130/webkit)

Added: trunk/LayoutTests/editing/execCommand/outdent-paragraph-crash-expected.txt (0 => 290249)


--- trunk/LayoutTests/editing/execCommand/outdent-paragraph-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/outdent-paragraph-crash-expected.txt	2022-02-21 18:07:18 UTC (rev 290249)
@@ -0,0 +1 @@
+Test passes if it does not crash.

Added: trunk/LayoutTests/editing/execCommand/outdent-paragraph-crash.html (0 => 290249)


--- trunk/LayoutTests/editing/execCommand/outdent-paragraph-crash.html	                        (rev 0)
+++ trunk/LayoutTests/editing/execCommand/outdent-paragraph-crash.html	2022-02-21 18:07:18 UTC (rev 290249)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <style>
+    :read-only::-webkit-scrollbar {
+      --a: var(--b), var(--c);
+    }
+  </style>
+  <script>
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    }
+    _onload_ = async () => {
+      visualViewport._onresize_ = () => {
+        document.execCommand('Outdent');
+        document.write("Test passes if it does not crash.");
+        testRunner.notifyDone();
+      };
+      let blockquote = document.createElement('blockquote');
+      document.body.append(blockquote);
+      let p = document.createElement('p');
+      blockquote.append(p);
+      document.body.append(document.createElement('object'));
+      blockquote.append(document.createElement('iframe'));
+      let blockquote2 = document.createElement('blockquote');
+      document.documentElement.append(document.createElement('object'));
+      p.append(blockquote2);
+      blockquote2.append(document.createElement('iframe'));
+      document.body.innerHTML += '';
+      document.execCommand('SelectAll');
+      let animation = new Animation();
+      animation.play();
+      await animation.ready;
+      document.designMode = 'on';
+      if (window.caches)
+        await caches.has('d');
+      document.body.replaceChildren();
+    };
+  </script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (290248 => 290249)


--- trunk/Source/WebCore/ChangeLog	2022-02-21 17:56:12 UTC (rev 290248)
+++ trunk/Source/WebCore/ChangeLog	2022-02-21 18:07:18 UTC (rev 290249)
@@ -1,3 +1,17 @@
+2022-02-21  Rob Buis  <[email protected]>
+
+        Null check parent node in outdentParagraph
+        https://bugs.webkit.org/show_bug.cgi?id=235914
+
+        Reviewed by Wenson Hsieh.
+
+        Null check parent node of enclosing node in outdentParagraph.
+
+        Test: editing/execCommand/outdent-paragraph-crash.html
+
+        * editing/IndentOutdentCommand.cpp:
+        (WebCore::IndentOutdentCommand::outdentParagraph):
+
 2022-02-21  Noam Rosenthal  <[email protected]>
 
         PerformanceObserver: buffered flag not working in Paint Timing

Modified: trunk/Source/WebCore/editing/IndentOutdentCommand.cpp (290248 => 290249)


--- trunk/Source/WebCore/editing/IndentOutdentCommand.cpp	2022-02-21 17:56:12 UTC (rev 290248)
+++ trunk/Source/WebCore/editing/IndentOutdentCommand.cpp	2022-02-21 18:07:18 UTC (rev 290249)
@@ -133,7 +133,7 @@
     VisiblePosition visibleEndOfParagraph = endOfParagraph(visibleStartOfParagraph);
 
     RefPtr enclosingNode = downcast<HTMLElement>(enclosingNodeOfType(visibleStartOfParagraph.deepEquivalent(), &isListOrIndentBlockquote));
-    if (!enclosingNode || !enclosingNode->parentNode()->hasEditableStyle()) // We can't outdent if there is no place to go!
+    if (!enclosingNode || !enclosingNode->parentNode() || !enclosingNode->parentNode()->hasEditableStyle()) // We can't outdent if there is no place to go!
         return;
 
     // Use InsertListCommand to remove the selection from the list
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to