Skip to content

Commit a574285

Browse files
authored
chore: cherry-pick 3abc372c9c00 from chromium (#26895)
* chore: cherry-pick 3abc372c9c00 from chromium * resolve conflict
1 parent 559c008 commit a574285

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

patches/chromium/.patches

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ make_macos_os_version_numbers_consistent.patch
155155
ignore_renderframehostimpl_detach_for_speculative_rfhs.patch
156156
ui_check_that_unpremultiply_is_passed_a_32bpp_image.patch
157157
cherry-pick-eec5025668f8.patch
158+
cherry-pick-3abc372c9c00.patch
158159
cherry-pick-d8d64b7cd244.patch
159160
cherry-pick-5ffbb7ed173a.patch
160161
propagate_disable-dev-shm-usage_to_child_processes.patch
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Xiaocheng Hu <xiaochengh@chromium.org>
3+
Date: Tue, 3 Nov 2020 23:00:29 +0000
4+
Subject: Apply markup sanitizer in CompositeEditCommand::MoveParagraphs()
5+
6+
CompositeEditCommand::MoveParagraphs() serailizes part of the DOM and
7+
then re-parse it and insert it at some other place of the document. This
8+
is essentially a copy-and-paste, and can be exploited in the same way
9+
how copy-and-paste is exploited. So we should also sanitize markup in
10+
the function.
11+
12+
(cherry picked from commit c529cbcc1bb0f72af944c30f03c2b3b435317bc7)
13+
14+
Bug: 1141350
15+
Change-Id: I25c1dfc61c20b9134b23e057c5a3a0f56c190b5c
16+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2500633
17+
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
18+
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
19+
Cr-Original-Commit-Position: refs/heads/master@{#821098}
20+
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518088
21+
Reviewed-by: Xiaocheng Hu <xiaochengh@chromium.org>
22+
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
23+
Cr-Commit-Position: refs/branch-heads/4280@{#1099}
24+
Cr-Branched-From: ea420fb963f9658c9969b6513c56b8f47efa1a2a-refs/heads/master@{#812852}
25+
26+
diff --git a/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc b/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc
27+
index a665fe438041cce473b195a606378ee26500ebc4..2ba9c0cd368b3b907320ef2d6de550ae7598779e 100644
28+
--- a/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc
29+
+++ b/third_party/blink/renderer/core/editing/commands/composite_edit_command.cc
30+
@@ -1492,19 +1492,18 @@ void CompositeEditCommand::MoveParagraphs(
31+
// FIXME: This is an inefficient way to preserve style on nodes in the
32+
// paragraph to move. It shouldn't matter though, since moved paragraphs will
33+
// usually be quite small.
34+
- DocumentFragment* fragment =
35+
- start_of_paragraph_to_move.DeepEquivalent() !=
36+
- end_of_paragraph_to_move.DeepEquivalent()
37+
- ? CreateFragmentFromMarkup(
38+
- GetDocument(),
39+
- CreateMarkup(start.ParentAnchoredEquivalent(),
40+
- end.ParentAnchoredEquivalent(),
41+
- CreateMarkupOptions::Builder()
42+
- .SetShouldConvertBlocksToInlines(true)
43+
- .SetConstrainingAncestor(constraining_ancestor)
44+
- .Build()),
45+
- "", kDisallowScriptingAndPluginContent)
46+
- : nullptr;
47+
+ DocumentFragment* fragment = nullptr;
48+
+ if (start_of_paragraph_to_move.DeepEquivalent() !=
49+
+ end_of_paragraph_to_move.DeepEquivalent()) {
50+
+ const String paragraphs_markup = CreateMarkup(
51+
+ start.ParentAnchoredEquivalent(), end.ParentAnchoredEquivalent(),
52+
+ CreateMarkupOptions::Builder()
53+
+ .SetShouldConvertBlocksToInlines(true)
54+
+ .SetConstrainingAncestor(constraining_ancestor)
55+
+ .Build());
56+
+ fragment = CreateSanitizedFragmentFromMarkupWithContext(
57+
+ GetDocument(), paragraphs_markup, 0, paragraphs_markup.length(), "");
58+
+ }
59+
60+
// A non-empty paragraph's style is moved when we copy and move it. We don't
61+
// move anything if we're given an empty paragraph, but an empty paragraph can

0 commit comments

Comments
 (0)