Highlighting password field then making a Sticky Note via Safari Services exposes...
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 01:02:15 +0000 (01:02 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Jan 2014 01:02:15 +0000 (01:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=126946

Reviewed by Enrica Casucci.

Using the Services menu has a slightly different codepath than Editor::copy() does. This
patch duplicates the canCopy() check that Editor::copy() does.

Testing is not possible because the Services menu is not accessible to our tests.

* editing/mac/EditorMac.mm:
(WebCore::Editor::stringSelectionForPasteboard):
(WebCore::Editor::stringSelectionForPasteboardWithImageAltText):
(WebCore::Editor::dataSelectionForPasteboard):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@161925 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/editing/mac/EditorMac.mm

index 8aa1a16141d90669ee84721d647ae65db058086c..020dc5f13cc3ab3c4fdbd5a62775c763e3e08154 100644 (file)
@@ -1,3 +1,20 @@
+2014-01-13  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Highlighting password field then making a Sticky Note via Safari Services exposes password
+        https://bugs.webkit.org/show_bug.cgi?id=126946
+
+        Reviewed by Enrica Casucci.
+
+        Using the Services menu has a slightly different codepath than Editor::copy() does. This
+        patch duplicates the canCopy() check that Editor::copy() does.
+
+        Testing is not possible because the Services menu is not accessible to our tests.
+
+        * editing/mac/EditorMac.mm:
+        (WebCore::Editor::stringSelectionForPasteboard):
+        (WebCore::Editor::stringSelectionForPasteboardWithImageAltText):
+        (WebCore::Editor::dataSelectionForPasteboard):
+
 2014-01-13  Brent Fulgham  <bfulgham@apple.com>
 
         [WebGL] Crash due to forceLostContext
 2014-01-13  Brent Fulgham  <bfulgham@apple.com>
 
         [WebGL] Crash due to forceLostContext
index b60d5c1ecf593c83710a68273ec640cb422c1026..7e01bdd557d226f8f088de2c5ec2b5c61cb7eff5 100644 (file)
@@ -269,6 +269,8 @@ void Editor::readSelectionFromPasteboard(const String& pasteboardName)
 // This was left in a bad state when selectedTextForClipboard was added. Need to look over clients and fix this.
 String Editor::stringSelectionForPasteboard()
 {
 // This was left in a bad state when selectedTextForClipboard was added. Need to look over clients and fix this.
 String Editor::stringSelectionForPasteboard()
 {
+    if (!canCopy())
+        return "";
     String text = selectedText();
     text.replace(noBreakSpace, ' ');
     return text;
     String text = selectedText();
     text.replace(noBreakSpace, ' ');
     return text;
@@ -276,6 +278,8 @@ String Editor::stringSelectionForPasteboard()
 
 String Editor::stringSelectionForPasteboardWithImageAltText()
 {
 
 String Editor::stringSelectionForPasteboardWithImageAltText()
 {
+    if (!canCopy())
+        return "";
     String text = selectedTextForClipboard();
     text.replace(noBreakSpace, ' ');
     return text;
     String text = selectedTextForClipboard();
     text.replace(noBreakSpace, ' ');
     return text;
@@ -324,6 +328,8 @@ PassRefPtr<SharedBuffer> Editor::dataSelectionForPasteboard(const String& pasteb
     // which is only used to support OS X services.
 
     // FIXME: Does this function really need to use adjustedSelectionRange()? Because writeSelectionToPasteboard() just uses selectedRange().
     // which is only used to support OS X services.
 
     // FIXME: Does this function really need to use adjustedSelectionRange()? Because writeSelectionToPasteboard() just uses selectedRange().
+    if (!canCopy())
+        return nullptr;
 
     if (pasteboardType == WebArchivePboardType)
         return selectionInWebArchiveFormat();
 
     if (pasteboardType == WebArchivePboardType)
         return selectionInWebArchiveFormat();