Title: [115650] trunk/Source/WebKit2
Revision
115650
Author
[email protected]
Date
2012-04-30 10:44:58 -0700 (Mon, 30 Apr 2012)

Log Message

        Validate keypress command names
        https://bugs.webkit.org/show_bug.cgi?id=85204
        <rdar://problem/11249368>

        Reviewed by Darin Adler.

        * UIProcess/API/mac/WKView.mm:
        (-[WKView doCommandBySelector:]):
        (-[WKView insertText:replacementRange:]):
        * UIProcess/WebPageProxy.h:
        (WebKit::WebPageProxy::registerKeypressCommandName):
        (WebKit::WebPageProxy::isValidKeypressCommandName):
        * UIProcess/mac/WebPageProxyMac.mm:
        (WebKit::WebPageProxy::executeSavedCommandBySelector):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (115649 => 115650)


--- trunk/Source/WebKit2/ChangeLog	2012-04-30 17:44:38 UTC (rev 115649)
+++ trunk/Source/WebKit2/ChangeLog	2012-04-30 17:44:58 UTC (rev 115650)
@@ -1,3 +1,20 @@
+2012-04-30  Alexey Proskuryakov  <[email protected]>
+
+        Validate keypress command names
+        https://bugs.webkit.org/show_bug.cgi?id=85204
+        <rdar://problem/11249368>
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView doCommandBySelector:]):
+        (-[WKView insertText:replacementRange:]):
+        * UIProcess/WebPageProxy.h:
+        (WebKit::WebPageProxy::registerKeypressCommandName):
+        (WebKit::WebPageProxy::isValidKeypressCommandName):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::executeSavedCommandBySelector):
+
 2012-04-30  Mario Sanchez Prada  <[email protected]>
 
         [GTK] Implement WebUIClient's runOpenPanel in WebKit2GTK+

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (115649 => 115650)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2012-04-30 17:44:38 UTC (rev 115649)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2012-04-30 17:44:58 UTC (rev 115650)
@@ -1138,9 +1138,11 @@
     // As in insertText:replacementRange:, we assume that the call comes from an input method if there is marked text.
     bool isFromInputMethod = _data->_page->editorState().hasComposition;
 
-    if (parameters && !isFromInputMethod)
-        parameters->commands->append(KeypressCommand(NSStringFromSelector(selector)));
-    else {
+    if (parameters && !isFromInputMethod) {
+        KeypressCommand command(NSStringFromSelector(selector));
+        parameters->commands->append(command);
+        _data->_page->registerKeypressCommandName(command.commandName);
+    } else {
         // FIXME: Send the command to Editor synchronously and only send it along the
         // responder chain if it's a selector that does not correspond to an editing command.
         [super doCommandBySelector:selector];
@@ -1185,7 +1187,9 @@
     // then we also execute it immediately, as there will be no other chance.
     if (parameters && !isFromInputMethod) {
         ASSERT(replacementRange.location == NSNotFound);
-        parameters->commands->append(KeypressCommand("insertText:", text));
+        KeypressCommand command("insertText:", text);
+        parameters->commands->append(command);
+        _data->_page->registerKeypressCommandName(command.commandName);
         return;
     }
 

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (115649 => 115650)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-04-30 17:44:38 UTC (rev 115649)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2012-04-30 17:44:58 UTC (rev 115650)
@@ -555,6 +555,11 @@
     bool isValidEditCommand(WebEditCommandProxy*);
     void registerEditCommand(PassRefPtr<WebEditCommandProxy>, UndoOrRedo);
 
+#if PLATFORM(MAC)
+    void registerKeypressCommandName(const String& name) { m_knownKeypressCommandNames.add(name); }
+    bool isValidKeypressCommandName(const String& name) const { return m_knownKeypressCommandNames.contains(name); }
+#endif
+
     WebProcessProxy* process() const;
     PlatformProcessIdentifier processIdentifier() const;
 
@@ -942,6 +947,10 @@
 
     HashSet<WebEditCommandProxy*> m_editCommandSet;
 
+#if PLATFORM(MAC)
+    HashSet<String> m_knownKeypressCommandNames;
+#endif
+
     RefPtr<WebPopupMenuProxy> m_activePopupMenu;
     RefPtr<WebContextMenuProxy> m_activeContextMenu;
     WebHitTestResult::Data m_activeContextMenuHitTestResultData;

Modified: trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm (115649 => 115650)


--- trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2012-04-30 17:44:38 UTC (rev 115649)
+++ trunk/Source/WebKit2/UIProcess/mac/WebPageProxyMac.mm	2012-04-30 17:44:58 UTC (rev 115650)
@@ -402,6 +402,8 @@
 
 void WebPageProxy::executeSavedCommandBySelector(const String& selector, bool& handled)
 {
+    MESSAGE_CHECK(isValidKeypressCommandName(selector));
+
     handled = m_pageClient->executeSavedCommandBySelector(selector);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to