Page MenuHomePhabricator

Copy-paste of wikitext from "Use this file" on Commons into VisualEditor does not work when the filename is too long because it's limited for performance
Closed, ResolvedPublic1 Estimated Story Points

Description

Copy-paste of wikitext from "Use this file" on Commons into VisualEditor does not work in all cases.

This option is here:

The following file works: https://commons.wikimedia.org/wiki/File:Kinder-Bueno-Split.jpg pasting [[File:Kinder-Bueno-Split.jpg|thumb|Kinder-Bueno-Split]] into VE generates a thumbnail.

The following file doesn't: https://commons.wikimedia.org/wiki/File:Cementerio,_Tulcán,_Ecuador,_2015-07-21,_DD_60.JPG pasting [[File:Cementerio, Tulcán, Ecuador, 2015-07-21, DD 60.JPG|thumb|Cementerio, Tulcán, Ecuador, 2015-07-21, DD 60]] just pastes it as text.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Hmm, it seems to be intentionally limited.

ve.ui.mwWikitextTransferRegistry.register(
	'internalLink',
	// [[...]] on a single line of max 80 characters
	/\[\[.{1,80}\]\]/m
);

https://gerrit.wikimedia.org/r/#/c/275193/ doesn't explain why :(

I think @cscott did this for performance.

Jdforrester-WMF renamed this task from Copy-paste of wikitext from "Use this file" on Commons into VisualEditor does not work in all cases to Copy-paste of wikitext from "Use this file" on Commons into VisualEditor does not work when the filename is too long because it's limited for performance.Nov 29 2016, 8:13 PM
Jdforrester-WMF triaged this task as Low priority.
Jdforrester-WMF set the point value for this task to 1.
Jdforrester-WMF moved this task from To Triage to TR1: Releases on the VisualEditor board.
Jdforrester-WMF added a subscriber: Jdforrester-WMF.

We could bump that to 250 or whatever but it could still be longer… If only MW used hashes rather than names to refer to images. ;-)

Right, so this was actually introduced in https://gerrit.wikimedia.org/r/#/c/230146/, but that doesn't explain why either. Originally it just checked for no newlines (without a length limit), this was changed in PS3, but I didn't find a rationale for it in the comments.

For template detection, we just look for '{{'. I'm pretty sure we could do the same for links, looking for '[['. Neither is likely to occur in normal text.

We could bump that to 250 or whatever but it could still be longer… If only MW used hashes rather than names to refer to images. ;-)

For this specific use case, it would have to be at least 526, by my count. And that would be silly.

Change 324514 had a related patch set uploaded (by Bartosz Dziewoński):
ve.ui.MWWikitextTransferRegistry: Just look for '[[' when detecting links

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

Change 324514 merged by jenkins-bot:
ve.ui.MWWikitextTransferRegistry: Just look for '[[' when detecting links

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