Last modified: 2013-11-07 19:15:45 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56927, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54927 - Parsoid renders template as comment, breaking serialization
Parsoid renders template as comment, breaking serialization
Status: RESOLVED FIXED
Product: Parsoid
Classification: Unclassified
General (Other open bugs)
unspecified
All All
: Normal normal
: ---
Assigned To: Arlo Breault
:
: 56722 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-03 17:56 UTC by Moriel Schottlender
Modified: 2013-11-07 19:15 UTC (History)
6 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Moriel Schottlender 2013-10-03 17:56:34 UTC
I simply deleted a word from the leading paragraph in the article below, and got this as diff:
https://he.wikipedia.org/w/index.php?title=%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9%3ANurick%2F%D7%91%D7%93%D7%99%D7%A7%D7%95%D7%AA_-_%D7%A2%D7%95%D7%A8%D7%9A_%D7%97%D7%96%D7%95%D7%AA%D7%99&diff=14670508&oldid=14667916

To reproduce: Revert to the previous version in that diff, edit the article in VE, and delete a word from the leading paragraph.
Comment 1 Roan Kattouw 2013-10-17 17:42:05 UTC
This is due to a Parsoid bug.

Example that Moriel gave me: http://parsoid.wmflabs.org/he/%D7%93%D7%A0%D7%99%D7%90%D7%9C_%D7%A8%D7%93%D7%A7%D7%9C%D7%99%D7%A3

HTML starts with:

<html><head>...</head><body>
<!--{"@type":"mw:Transclusion","attrs":[{"name":"typeof","value":"mw:Transclusion"},{"name":"about","value":"#mwt1"},{"name":"id","value":"mwt1"},{"name":"data-mw-arginfo","value":"{\"dict\":{\"target\":{\"wt\":\"שחקנים
\\n\",\"href\":\"./תבנית:שחקנים\"},\"params\":{\"שם\":{\"wt\":\"דניאל רדקליף\"},\"תמונה\":{\"wt\":\"[[קובץ:Daniel Radcliffe Paris 2012.jpg|200px]]\"},\"כיתוב\":{\"wt\":\"<small> דניאל רדקליף, [[2012]]</small>\"},\"תאריך לידה\":{\"wt\":\"23 ביולי 1989\"},\"מקום לידה\":{\"wt\":\"[[לונדון]], [[אנגליה]], [[הממלכה המאוחדת]]\"},\"כינוי\":{\"wt\":\"דן\"},\"דמות\":{\"wt\":\"[[הארי פוטר (דמות)|הארי פוטר]]\"},\"בכורה\":{\"wt\":\"בסדרה [[דייוויד קופרפילד]], 1999\"},\"אתר אינטרנט\":{\"wt\":\"http://www.danradcliffe.co.uk/\"},\"קישור\":{\"wt\":\"0705356\"}}},\"paramInfos\":[{\"k\":\"שם\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"
\\n\"]},{\"k\":\"תמונה\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"כיתוב\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"תאריך לידה\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"מקום לידה\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"כינוי\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"דמות\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"בכורה\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"אתר אינטרנט\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]},{\"k\":\"קישור\",\"named\":true,\"spc\":[\"\",\"\",\"\",\"\\n\"]}]}"},{"name":"data-parsoid","value":"{\"tsr\":[0,356],\"src\":\"{{שחקנים
\\n|שם=דניאל רדקליף
\\n|תמונה=[[קובץ:Daniel Radcliffe Paris 2012.jpg|200px]]\\n|כיתוב=<small> דניאל רדקליף, [[2012]]</small>\\n|תאריך לידה=23 ביולי 1989\\n|מקום לידה=[[לונדון]], [[אנגליה]], [[הממלכה המאוחדת]]\\n|כינוי=דן\\n|דמות=[[הארי פוטר (דמות)|הארי פוטר]]\\n|בכורה=בסדרה [[דייוויד קופרפילד]], 1999\\n|אתר אינטרנט=http://www.danradcliffe.co.uk/\\n|קישור=0705356\\n}}\",\"tagId\":1}"}]}-->
<table class="infobox" style="width:18em; font-size:85%;" cellspacing="5" about="#mwt1" data-parsoid="{}">[....]</table>
<meta typeof="mw:Transclusion/End" about="#mwt1" data-parsoid="{&quot;dsr&quot;:[null,356,null,null]}">

Note how:
* The transclusion starts with a comment (!) which tries to be in the #mwt1 about group
* The transclusion continues with a table in that same about group
* The about group ends with a meta tag in that same about group

This doesn't serialize cleanly at all, the template gets inserted into the wikitext and the table gets serialized as wikitext as well. Even the <meta> tag gets serialized: http://parsoid.wmflabs.org/_rt/he/%D7%93%D7%A0%D7%99%D7%90%D7%9C_%D7%A8%D7%93%D7%A7%D7%9C%D7%99%D7%A3

In VisualEditor, this causes:
* corruption on save like in the diff Moriel linked
* the user to be able to edit inside the infobox, because the comment is ignored and there are no attributes on the <table> telling VE it's part of a template (there's about="#mwt1" but that doesn't refer back to a valid about group, so it's interpreted as the start of an about group)
Comment 2 Arlo Breault 2013-10-19 02:33:07 UTC
The problem here is that the contents of that comment isn't matching this regex,

  /^\{.*\}$/.test( content )

https://github.com/wikimedia/mediawiki-extensions-Parsoid/blob/master/js/lib/mediawiki.DOMPostProcessor.js#L95

It's not recognizing the last character as }. Taking content.charCodeAt( content.length - 1 ) returns undefined. Probably because of the unicode characters. Switching to something like,

  /^\{\"@type\"/.test( content )

seems to work but I'm interested to see where exactly things are going wrong.
Comment 3 Arlo Breault 2013-10-19 03:07:10 UTC
On second thought, I think it's because `.` doesn't match newline chars.
Comment 4 Gerrit Notification Bot 2013-10-19 03:09:28 UTC
Change 90687 had a related patch set uploaded by Arlolra:
Match all characters when testing comments for JSON

https://gerrit.wikimedia.org/r/90687
Comment 5 Gerrit Notification Bot 2013-10-23 18:11:49 UTC
Change 90687 merged by jenkins-bot:
Match all characters when testing comments for JSON

https://gerrit.wikimedia.org/r/90687
Comment 6 Arlo Breault 2013-11-07 19:15:45 UTC
*** Bug 56722 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links