Page MenuHomePhabricator

NWE encodes linebreaks as \r\n but post-Parsoid wikitext is \n
Closed, ResolvedPublic1 Estimated Story Points

Description

Steps to reproduce:

  1. Open an article (with more than one line) for editing in VE.
  2. Execute:
(function () {
	var target = ve.init.target;
	target.serialize(target.getDocToSave(), function (wikitext) {
		console.log(wikitext.indexOf('\r\n'));
	});
})();

Actual and expected result: the console shows -1, as linebreaks should be encoded just using \n.

  1. Switch to NWE.
  2. Repeat step 2.

Expected result: Again -1.
Actual result: Some positive number, for some reason now all linebreaks are encoded as \r\n (which will be normalized on saving, but is confusing if you work with the generated wikitext yourself).

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
Jdforrester-WMF renamed this task from Inconsistent encoding of linebreaks to NWE encodes linebreaks as \r\n but post-Parsoid wikitext is \n.Mar 14 2017, 7:04 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.
matmarex changed the task status from Open to Stalled.Nov 5 2019, 4:30 PM
matmarex subscribed.

I can't reproduce this. I don't know when it was fixed, but maybe with T203156 or T205564?

Is this browser depended? I still can reproduce with Firefox. E.g. on https://de.wikipedia.org/wiki/Benutzer:Schnark?veaction=editsource the above code logs 39.

Yes, I also see this in Firefox now.

Apparently serialize() in wikitext mode sends the wikitext to the API just to receive it back. This seems useless but I don't really want to investigate why we do that. But the issue here happens because of this – apparently Firefox changes all the newlines to \r\n when sending, and we don't normalize them.

Change 550764 had a related patch set uploaded (by Bartosz Dziewoński; owner: Bartosz Dziewoński):
[mediawiki/extensions/VisualEditor@master] ApiVisualEditorEdit: Normalize newlines in wikitext

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

Change 550764 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] ApiVisualEditorEdit: Normalize newlines in wikitext

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

matmarex changed the task status from Stalled to Open.Dec 13 2019, 5:02 PM
matmarex edited projects, added VisualEditor (Current work); removed VisualEditor.
matmarex added a project: Skipped QA.
ppelberg claimed this task.