Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index 19d77afcb8e6d2c02e924007454be93d07f6d5fe..2e57d5499e68a225889711bbff4c1bc31ff51026 100644 |
| --- a/Source/core/dom/Document.cpp |
| +++ b/Source/core/dom/Document.cpp |
| @@ -4151,6 +4151,22 @@ static Editor::Command command(Document* document, const String& commandName, bo |
| bool Document::execCommand(const String& commandName, bool userInterface, const String& value) |
| { |
| + // We don't allow recusrive |execCommand()| to protect against attack code. |
| + // Recursive call of |execCommand()| could be happened by moving iframe |
| + // with script triggered by insertion, e.g. <iframe src="javascript:..."> |
| + // <iframe onload="...">. This usage is valid as of the specification |
| + // although, it isn't common use case, rather it is used as attack code. |
| + static bool inExecCommand = false; |
| + if (inExecCommand) { |
| + String message = "document.execCommand() is called recursively. Please revise event handler to avoid calling document.execCommand() recursively."; |
|
tkent
2014/01/29 07:56:06
Please say that we won't execute document.execComm
yosin_UTC9
2014/01/29 08:06:42
Done.
|
| + addConsoleMessage(JSMessageSource, WarningMessageLevel, message); |
| + return false; |
| + } |
| + TemporaryChange<bool> executeScope(inExecCommand, true); |
| + |
| + // Postpone DOM mutation events, which can execute scripts and change |
| + // DOM tree against implementation assumption. |
| + EventQueueScope eventQueueScope; |
| return command(this, commandName, userInterface).execute(value); |
| } |