Page MenuHomePhabricator

Annotations and templates misnesting don't wrap correctly around each other
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

Setup Parsoid with Translate activated, either by running it in --integrated mode backed by a Translate-enabled wiki, or by temporarily patching with some variation of https://www.mediawiki.org/wiki/Parsoid/Debugging#Debugging_Translate_annotations.

Run

$ echo "{{1x|<div>hello}} world <translate>plop replop</div></translate>" | php ./bin/parse.php --integrated

and then

echo "{{1x|<div>hello}} world <translate>plop replop</div></translate>" | php ./bin/parse.php --integrated --wt2wt

What happens?:

The results of these commands is as follows:

<div typeof="mw:ExtendedAnnRange" about="#mwt1" data-parsoid='{"autoInsertedStart":true,"autoInsertedEnd":true,"dsr":[24,64,0,0]}'><meta typeof="mw:Annotation/translate" about="#mwt1" data-parsoid='{"dsr":[24,35,null,null],"wasMoved":true}' data-mw='{"rangeId":"mwa0","extendedRange":true,"wtOffsets":[24,35]}'/><div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","dsr":[0,52,null,6],"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>hello"}},"i":0}}," world &lt;translate>plop replop&lt;/div>"]}'>hello world plop replop</div><meta typeof="mw:Annotation/translate/End" data-parsoid='{"dsr":[52,64,null,null]}' data-mw='{"wtOffsets":[52,64]}'/></div>
<translate>
{{1x|<div>hello}} world <translate>plop replop</div>
</translate>

The beginning of the range is messy, and wt2wt gets lost and duplicates the <translate> opening tag.

What should have happened instead?:
The transclusion should probably extend to the ExtendedRange, and wt2wt should not duplicate the <translate> tag.

Note

In practice this specific case should not be much of a problem, because both the ExtendedAnnRange and the transclusion range forbid the editing of this section; so selser normally kicks in and we avoid round-tripping issues.