"Unsafe Paste" Dialogue pastes current selection, NOT prompted selection
If the primary selection changes after the dialogue window appears and before the paste action is confirmed, new/unknown data is pasted rather than what is presented in the dialogue's preview.
This seems like a classic TOCTOU issue: the dialogue inspects the selection/clipboard content once, displays it in the window and then rereads selection/clipboard contents again to actually paster.
Found by pausing work in one terminal, selecting text with the mouse in another window, then going back to the terminal and confirming the paste.
I'd argue that the "Unsafe Paste" dialogue should either abort pasting new/unknown data or save the initial data and paste that, regardless of selection/clipboard content at the time of confirmation.
Attached are two screenshots that illustrate the issue.
printf '%s\n' 1 2 | xclip -i
is used to fill the clipboard, middle-mouse click is used to paste in the same terminal.
The dialogue appears, I open another terminal and select something else (triple-click on the line), then confirm the paste.
Oops.