Bug 17645 - DOM ClipboardData.setData does not allow writes during clipboard events
Summary: DOM ClipboardData.setData does not allow writes during clipboard events
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Windows XP
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
: 25715 34020 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-02 23:18 PST by Mark Rowe (bdash)
Modified: 2023-04-06 04:55 PDT (History)
8 users (show)

See Also:


Attachments
Test case showing clipboard not working (688 bytes, text/html)
2008-03-03 10:21 PST, Nicholas C. Zakas
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Rowe (bdash) 2008-03-02 23:18:08 PST
* SUMMARY
The current ClipboardWin implementation does not allow writing to the system clipboard.  This affects DOM clipboard events.

This prevents developers from writing custom content to the system clipboard during DOM clipboard events (eg. cut, copy, paste)
Comment 1 Mark Rowe (bdash) 2008-03-02 23:18:39 PST
<rdar://problem/5015941>
Comment 2 Nicholas C. Zakas 2008-03-03 10:21:59 PST
Created attachment 19495 [details]
Test case showing clipboard not working

In theory, you should be able to override the default copy/cut behavior of the clipboard and set your own data. This example overrides the default copy behavior and shows that the call to setData() does not result in text being put on the clipboard.

User agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/523.15 (KHTML, like Gecko) Version/3.0 Safari/523.15

The same example works fine on Macintosh.
Comment 3 Dimitri Glazkov 2008-08-13 15:34:57 PDT
I am wondering why we couldn't get away with wiring the generic Pasteboard::writeURL, etc. into ClipboardWin for non-drag operations?

olliej mentioned on #webkit that the problem is in setData deleting existing clipboard content, but I am not sure I understand why this is the problem.
Comment 4 Ryosuke Niwa 2011-01-05 23:13:07 PST
*** Bug 34020 has been marked as a duplicate of this bug. ***
Comment 5 Ryosuke Niwa 2011-01-05 23:13:20 PST
*** Bug 25715 has been marked as a duplicate of this bug. ***
Comment 6 Nanne Wielinga 2023-04-06 04:55:35 PDT
Similar kind of bug related to: clipboardData.setData

If there is a : inside one of the line from data, then all the enters are removed.

Example: https://jsfiddle.net/pzqe18dw/
Copy from bottom textarea and paste somewhere else.

Code:
clipboardData.setData("text/plain", `test: 1\ntest2\ntest3`)

Results into (broken):

test: 1test2test3

Instead of (expected):

test: 1
test2
test3