| … | … | @@ -423,48 +427,206 @@ const editingCommand = (key: string, modifiers: number) => { | |
| 541 | + | transfer[method] = new Proxy(changeData, { | |
| 542 | + | apply(target, self, args) { | |
| 543 | + | const result = Reflect.apply(target, self, args); | |
| 544 | + | report("${CLIPBOARD_DATA_EVENT}", Reflect.apply(getData, self, ["text/plain"])); | |
🟠High preview/ServerBrowser.ts:544
A prevented copy handler can end up copying the wrong text: mutating an unrelated new DataTransfer() reports into the same pending copy event and overwrites the text from event.clipboardData, so the direct Cmd+C path forwards the unrelated value. Associate setData and item-list reports with the copy event’s actual clipboardData transfer before accepting them.
🤖 Copy this AI Prompt to have your agent fix this:
| 1 | In file @apps/server/src/preview/ServerBrowser.ts around line 544: |
| 2 | |
| 3 | A prevented `copy` handler can end up copying the wrong text: mutating an unrelated `new DataTransfer()` reports into the same pending copy event and overwrites the text from `event.clipboardData`, so the direct Cmd+C path forwards the unrelated value. Associate `setData` and item-list reports with the copy event’s actual `clipboardData` transfer before accepting them. |
Fixed in 9ee800f. A data report is now accepted only while the trusted copy or cut event is still running, and only when the changed transfer is that event's own clipboardData. That covers setData, clearData and the items add, remove and clear calls, on both the click and Cmd+C paths. The "keeps the final copy and cut payload" table still changes a new DataTransfer() inside the handler and asserts the page's own text is kept, and that table fails when the check is removed.
Sorry, I'm unable to act on this request because you do not have permissions within this repository.