Page MenuHomePhabricator

VisualEditor: Improperly escapes <nowiki>
Closed, ResolvedPublic

Description

If I input <nowiki>a</nowiki> in VE, save the page, then go back to the editor, text is broken in VE there.


Version: unspecified
Severity: normal

Details

Reference
bz37838

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 12:30 AM
bzimport added a project: Parsoid.
bzimport set Reference to bz37838.

Mass-moving items into VisualEditor product

Input HTML: <nowiki>a</nowiki>

Actual output wikitext after RT: <nowiki>&lt;nowiki&gt;</nowiki>a<nowiki>&lt;/nowiki&gt;</nowiki>

Expected wikitext: ???

I would expect as wikitext: &lt;nowiki&gt;a&lt;/nowiki&gt;

Actually a Parsoid bug, moving.

Cannot replicate this either at http://parsoid.wmflabs.org/_html/ or on my CLI (excess newlines trimmed below) with the current HEAD.


[subbu@earth lib] echo "<nowiki>a</nowiki>" | node parse.js --html2wt
<nowiki>a</nowiki>

[subbu@earth lib] echo "<nowiki>a</nowiki>" | node parse.js --html2wt | node parse.js
<p><span typeof="mw:Nowiki" data-parsoid="{&quot;tsr&quot;:[0,8],&quot;bsp&quot;:[0,18]}">a</span></p>

[subbu@earth lib] echo "<nowiki>a</nowiki>" | node parse.js --html2wt | node parse.js | node parse.js --html2wt
<nowiki>a</nowiki>


Either VE is using an older Parsoid version -- or something else is broken.

Oh, never mind. I got it wrong. So, the input is not what I tested against. The text to test is "&lt;nowiki&gt;a&lt;/nowiki&gt;

<nowiki> is invalid HTML. The DOM representation of nowiki is <span typeof="mw:Nowiki">, which round-trips ok. Not sure if the VE handles this properly right now.

<nowiki> in a DOM text node (&lt;nowiki&gt; when entered in the HTML -> wikitext test form) properly serializes to &lt;nowiki&gt;.

Please test round-trip stuff on http://parsoid.wmflabs.org/ if possible ;)

Hmm- seems as if I made a mistake while testing this. There might be a Parsoid bug after all.

So to be entirely clear:

$ echo "&lt;nowiki&gt;a&lt;/nowiki&gt;" | node parse.js --html2wt

actual
<nowiki>&lt;nowiki&gt;</nowiki>a<nowiki>&lt;/nowiki&gt;</nowiki>

expected

&lt;nowiki&gt;a&lt;/nowiki&gt;

The problem is pretty clearly in mw.WikitextSerializer.js, near line 152, in the function wrapNonTextTokens. The serializer escapes any instances of <\/?nowiki> with its HTML-entitied counterpart, then wraps it in <nowiki>. I don't know why right now.

git blame seems to think Gabriel would know :)

[Parsoid component reorg by merging CPP/* tickets into General. See bug 50685 for more information. Filter bugmail on this comment. parsoidreorg20130704]