haikuwebkit/LayoutTests/editing
commit-queue@webkit.org 76f3f97c6e Nullptr deref in WebCore::ApplyStyleCommand::applyRelativeFontStyleChange
https://bugs.webkit.org/show_bug.cgi?id=223364

Patch by Frédéric Wang <fwang@igalia.com> on 2021-03-23
Reviewed by Ryosuke Niwa.

Source/WebCore:

When the editing code creates a span to apply font style change, it may not have editable
style if the document sets extra style (e.g. user-select: all). This is causing a debug
ASSERT in AppendNodeCommand::AppendNodeCommand when the span is inserted and a nullptr
dereference later in release mode. This patch ensures that we skip the font style change
when that happens.

Test: editing/style/apply-font-style-change-crash.html

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyRelativeFontStyleChange): Skip the font style change if
the span insertion failed.
(WebCore::ApplyStyleCommand::surroundNodeRangeWithElement): After inserting the new element,
ensure that the conditions from the ASSERT of AppendNodeCommand::AppendNodeCommand hold and
return failure if they don't.
* editing/ApplyStyleCommand.h: Return a boolean indicating success.

LayoutTests:

Add regression test.

* editing/style/apply-font-style-change-crash-expected.txt: Added.
* editing/style/apply-font-style-change-crash.html: Added.

Canonical link: https://commits.webkit.org/235647@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274865 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-03-23 13:55:33 +00:00
..
async-clipboard
caret
deleting Crash in InsertTextCommand::doApply 2021-02-12 11:29:32 +00:00
editability
editable-region
execCommand
find
input
inserting
mac
pasteboard [Cocoa] Strip DataDetectors links when copying content to the pasteboard 2021-01-15 02:00:26 +00:00
resources
secure-input
selection Nullopt in DOMSelection::getRangeAt 2021-03-23 13:37:46 +00:00
spelling
style
text-iterator
text-placeholder
undo
undo-manager
unsupported-content
document-marker-null-check-expected.txt
document-marker-null-check.html
editing.js
editingStyle.css