Page MenuHomePhabricator

Pasting into a VE surface in Firefox adds spurious line breaks and nowikis
Closed, ResolvedPublic8 Estimated Story Points

Description

Copy a fairly long chunk of text (at least 100 words or so—the first several paragraphs of https://wikimediafoundation.org/wiki/FAQ/en will do fine) in Firefox. It will contain a number of single line breaks that do not exist in the source (but often come at or within a couple of words of the displayed line breaks). These breaks will persist when the content is pasted into VE; where they come right before a space, Parsoid will be forced to wrap the space in <nowiki> tags.

For example, the source HTML

<p><a class="external text" href="//www.wikipedia.org">Wikipedia</a> is the world's largest and most popular encyclopedia. It is online, free to use for any purpose, and free of advertising. Wikipedia contains more than 35 million volunteer-authored articles in over 288 languages, and is visited by more than 439 million people every month, making it one of the most popular sites in the world. 
</p>

<p>It is a collaborative creation that has been added to and edited by millions of people during the past twelve years: anyone can edit it, at any time. It has become the largest collection of shared knowledge in human history. The people who support it are united by their love of learning, their intellectual curiosity, and their awareness that we know much more together than any of us does alone.
</p>

is copied as:

<p><a class="external text" href="https://www.wikipedia.org">Wikipedia</a>
 is the world's largest and most popular encyclopedia. It is online, 
free to use for any purpose, and free of advertising. Wikipedia contains
 more than 35 million volunteer-authored articles in over 288 languages,
 and is visited by more than 439 million people every month, making it 
one of the most popular sites in the world. 
</p><p>It is a collaborative creation that has been added to and edited 
by millions of people during the past twelve years: anyone can edit it, 
at any time. It has become the largest collection of shared knowledge in
 human history. The people who support it are united by their love of 
learning, their intellectual curiosity, and their awareness that we know
 much more together than any of us does alone.
</p>

which leads to the saved wikitext:

Wikipedia
<nowiki> </nowiki>is the world's largest and most popular encyclopedia. It is online, 
free to use for any purpose, and free of advertising. Wikipedia contains
<nowiki> </nowiki>more than 35 million volunteer-authored articles in over 288 languages,
<nowiki> </nowiki>and is visited by more than 439 million people every month, making it 
one of the most popular sites in the world.

It is a collaborative creation that has been added to and edited 
by millions of people during the past twelve years: anyone can edit it, 
at any time. It has become the largest collection of shared knowledge in
<nowiki> </nowiki>human history. The people who support it are united by their love of 
learning, their intellectual curiosity, and their awareness that we know
<nowiki> </nowiki>much more together than any of us does alone.

Event Timeline

nshahquinn-wmf raised the priority of this task from to High.
nshahquinn-wmf updated the task description. (Show Details)
nshahquinn-wmf subscribed.
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
nshahquinn-wmf renamed this task from Copying and pasting between VE surfaces in Firefox adds spurious line breaks and nowikis to Pasting into a VE surface in Firefox adds spurious line breaks and nowikis.Jul 5 2015, 6:54 AM
nshahquinn-wmf updated the task description. (Show Details)
nshahquinn-wmf set Security to None.
nshahquinn-wmf added a subscriber: NicoV.

Reversing direction of the merge since this task is more detailed.

At home and by Vatadoshu too, VE does not add nowiki markups : VE automatically delete spaces when they are between a carriage return and a word.
The spaces are remains after pasting but they do not appear in "View changes" (before saving) and they are deleted when submitting.
(I hope my bad English is understandable.)

Jdforrester-WMF assigned this task to Esanders.

This looks like it was fixed in the changes two weeks ago.

Unfortunately, I can still reproduce this (using the instructions in the description) on enwiki and the beta cluster using Firefox 44.0a2. The linebreaks do persist after saving.

I remain unable to replicate with wmf.5 or later. Can you re-test?

@Jdforrester-WMF, it looks like it's been partially fixed. I've tested several times and haven't got any nowikis even when there were spaces immediately after linebreaks.

However, the single linebreaks themselves still exist (I've checked both Firefox 44.0a2 and 43.0b3), which looks ugly in both the visual editor and the wikitext editor. Check this diff, for example.

Yeah I see this. I guess we can replace newlines with spaces on external import...

Change 254609 had a related patch set uploaded (by Esanders):
ElementLinearData: Sanitize away plain text linebreak characters

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

Change 254609 merged by jenkins-bot:
ElementLinearData: Sanitize away plain text linebreak characters

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

@Esanders
It is better, but now there are 2 spaces everywhere where there was a line break before.
I think the line breaks should be replaced by the empty string rather than by a space.