Page MenuHomePhabricator

Paste special should bypass autolink functionality
Closed, ResolvedPublic1 Estimated Story Points

Description

If the user has gone out of their way to hit CTRL+SHIFT+V, it's safe to assume they are an advanced user...

Event Timeline

Esanders assigned this task to cscott.
Esanders raised the priority of this task from to Needs Triage.
Esanders updated the task description. (Show Details)
Esanders added a project: VisualEditor.
Esanders subscribed.

What are the actual intended semantics of "Paste Special"?

Again, this seems to be a generic paste-handler issue, if "Paste Special" is intended to mean "use the plaintext handler" or something like that.

What are the actual intended semantics of "Paste Special"?

"Paste exactly clipboard as plain-text without interpretation"

Jdforrester-WMF set Security to None.
Jdforrester-WMF edited a custom field.

Ok. But this should also not be autolink specific. "Paste Special" should hard code the PlainTextStringTransferHandler and not go looking for better handlers.

Perhaps the issue is that "Paste Special" is filtering out all but the text/plain item, but not actually hard coding the correct handler. It just happened to be lucky that there was only one text/plain handler before. (Well, actually, I guess that was a limitation of the old registration mechanism, which only allowed a single handler per type.)

Hm. ve.ce.Surface seems to use a different semantics for pasteSpecial which is "sanitize the data by stripping down to plain text after pasting". The pasteSpecial field appears to affect only the importRules used.

Of course, apparently the { all: { plainText: true } } importRules aren't actually being applied, or we wouldn't be seeing this to begin with. But is this the way we really want to handle pasteSpecial?

Yes - the fix should not be specific to autolink - I was just giving an example of the bug.

I think what I called "paste special" in the code should mean plain text, and the output should contain no formatting. That would include not running paste handlers.

Change 233039 had a related patch set uploaded (by Cscott):
Don't autolink or autoconvert on "Paste Special"

https://gerrit.wikimedia.org/r/233039

I tried enforcing the use of the PlainTextStringHandler on "paste special" but the results were suboptimal. As @Esanders suggested, just bypassing all our special handlers seems to work better -- even though this is really using the native "paste html" handler and then stripping out the html markup. It's possible that some paste sources might have a "better" plain text item which we ought to use. For example, when doing a "paste special" on an HTML table, Firefox (at least) has some nice tab-delimited plain text.

Anyway, the attached patch works and is simple. Seems the best thing to do until/unless we have a compelling alternate use case.

Change 233039 merged by jenkins-bot:
Don't autolink or autoconvert on "Paste Special"

https://gerrit.wikimedia.org/r/233039