Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: Source/core/editing/CompositeEditCommand.cpp

Issue 71163005: Prevent recursive call of Document::execCommand() to protect from attack code (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 2013-11-13T18:35:41 Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/editing/execCommand/apply-style-iframe-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 CompositeEditCommand::CompositeEditCommand(Document& document) 149 CompositeEditCommand::CompositeEditCommand(Document& document)
150 : EditCommand(document) 150 : EditCommand(document)
151 { 151 {
152 } 152 }
153 153
154 CompositeEditCommand::~CompositeEditCommand() 154 CompositeEditCommand::~CompositeEditCommand()
155 { 155 {
156 ASSERT(isTopLevelCommand() || !m_composition); 156 ASSERT(isTopLevelCommand() || !m_composition);
157 } 157 }
158 158
159 static int applyNestingCounter;
160
159 void CompositeEditCommand::apply() 161 void CompositeEditCommand::apply()
160 { 162 {
163 if (applyNestingCounter)
164 return;
165
161 if (!endingSelection().isContentRichlyEditable()) { 166 if (!endingSelection().isContentRichlyEditable()) {
162 switch (editingAction()) { 167 switch (editingAction()) {
163 case EditActionTyping: 168 case EditActionTyping:
164 case EditActionPaste: 169 case EditActionPaste:
165 case EditActionDrag: 170 case EditActionDrag:
166 case EditActionSetWritingDirection: 171 case EditActionSetWritingDirection:
167 case EditActionCut: 172 case EditActionCut:
168 case EditActionUnspecified: 173 case EditActionUnspecified:
169 break; 174 break;
170 default: 175 default:
171 ASSERT_NOT_REACHED(); 176 ASSERT_NOT_REACHED();
172 return; 177 return;
173 } 178 }
174 } 179 }
175 ensureComposition(); 180 ensureComposition();
176 181
177 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>. 182 // Changes to the document may have been made since the last editing operati on that require a layout, as in <rdar://problem/5658603>.
178 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one 183 // Low level operations, like RemoveNodeCommand, don't require a layout beca use the high level operations that use them perform one
179 // if one is necessary (like for the creation of VisiblePositions). 184 // if one is necessary (like for the creation of VisiblePositions).
180 document().updateLayoutIgnorePendingStylesheets(); 185 document().updateLayoutIgnorePendingStylesheets();
181 186
182 Frame* frame = document().frame(); 187 Frame* frame = document().frame();
183 ASSERT(frame); 188 ASSERT(frame);
184 { 189 {
185 EventQueueScope scope; 190 EventQueueScope scope;
191 ++applyNestingCounter;
leviw_travelin_and_unemployed 2013/11/13 21:16:18 I like the idea... Can we make this RAII instead?
186 doApply(); 192 doApply();
193 --applyNestingCounter;
187 } 194 }
188 195
189 // Only need to call appliedEditing for top-level commands, 196 // Only need to call appliedEditing for top-level commands,
190 // and TypingCommands do it on their own (see TypingCommand::typingAddedToOp enCommand). 197 // and TypingCommands do it on their own (see TypingCommand::typingAddedToOp enCommand).
191 if (!isTypingCommand()) 198 if (!isTypingCommand())
192 frame->editor().appliedEditing(this); 199 frame->editor().appliedEditing(this);
193 setShouldRetainAutocorrectionIndicator(false); 200 setShouldRetainAutocorrectionIndicator(false);
194 } 201 }
195 202
196 EditCommandComposition* CompositeEditCommand::ensureComposition() 203 EditCommandComposition* CompositeEditCommand::ensureComposition()
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 return node.release(); 1470 return node.release();
1464 } 1471 }
1465 1472
1466 PassRefPtr<Element> createBlockPlaceholderElement(Document& document) 1473 PassRefPtr<Element> createBlockPlaceholderElement(Document& document)
1467 { 1474 {
1468 RefPtr<Element> breakNode = document.createElement(brTag, false); 1475 RefPtr<Element> breakNode = document.createElement(brTag, false);
1469 return breakNode.release(); 1476 return breakNode.release();
1470 } 1477 }
1471 1478
1472 } // namespace WebCore 1479 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/execCommand/apply-style-iframe-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698