(4) To show a dialog showing the actual copied content if the content does not match the rendered visible content of the selection.
(4) To show a dialog showing the actual copied content if the content does not match the rendered visible content of the selection.
(4) is better but it would have to be every single time, because (2) is impossible to define.
It's like spam: a precise closed-form analytical definition is impossible, but spam filters do work.
Browser vendors could hypothetically start adding specific types of exceptions to make certain types of the 'hidden box' trick not work, but that would ultimately mean those website developers simply switch to whatever method works. The problem isn't solved, it's just re-coded.
TLDR: There is NO SOLUTION, because there is NO PROBLEM. The feature works as intended, as written in the spec.
(I say this as a matter of how you express such things, not about this particular case. I agree with you in considering there to be no bug here, but rather that this is a serious feature that shouldn’t be messed with—and pretty fundamentally can’t without unravelling substantial foundations of the web platform.)
I suspect that for the great majority of practical cases, it is possible.
Where a definite answer is too hard to achieve, it's safe to err on the side of "not visible".
The bad guys aren't going to be using the great majority of practical cases.
The key principle of security is to deny all, allow a closed subset. Same here: allow what is obviously clear and has no hidden parts, and ask a confirmation for all the rest, legitimate or not.
I'm in favor of two-tier system where rich applications require permission for enhanced clipboard events but the average site will just copy what is selected without modification.
It's nowhere close to a solved problem, and is much more complex than this. Give a read through the comments in the OP for a taste of why.
Maybe there are deep reasons why it's impossible, but they are not well presented in the OP, unfortunately.