Page MenuHomePhabricator

Old syntax tvar breaks templates
Closed, ResolvedPublicBUG REPORT

Description

When an old syntax tvar (<tvar|var>) is used in a template, it breaks the template because the | is seen as a new argument separator.

As an example:

$ echo '{{1x|<tvar|1d>test</> test}}' | php bin/parse.php --wt2html --scrubWikitext
<p data-parsoid='{"dsr":[0,28,0,0]}'><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]],"dsr":[0,28,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;tvar|1d>test&lt;/> test"}},"i":0}}]}'>&lt;tvar</span></p>

We'd expect the "test" content to be visible akin to this:

$ echo '{{1x|<tvar>test</tvar> test}}' | php bin/parse.php --wt2html 
<p data-parsoid='{"dsr":[0,29,0,0]}'><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]],"dsr":[0,29,null,null]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;tvar>test&lt;/tvar> test"}},"i":0}}]}'>test test</span></p>

Related Objects

View Standalone Graph
This task is connected to more than 200 other tasks. Only direct parents and subtasks are shown here. Use View Standalone Graph to show more of the graph.
StatusSubtypeAssignedTask
Resolvedihurbain
ResolvedBUG REPORTihurbain

Event Timeline

I am borderline inclined to decline this ... one more reason to see if we can get old syntax migrated over with bots, etc. cc @Nikerabbit

Arlolra triaged this task as Medium priority.Nov 24 2021, 5:33 PM
Arlolra moved this task from Needs Triage to Known Differences on the Parsoid board.
Arlolra subscribed.

When an old syntax tvar (<tvar|var>) is used in a template, it breaks the template because the | is seen as a new argument separator.

Noting because I was confused, there's nothing wrong with the tokenization here,

0-[peg]        | ---->   [{"type":"SelfclosingTagTk","name":"template","attribs":[{"k":"1x","v":"","srcOffsets":[2,4,4,4]},{"k":"","v":[{"type":"SelfclosingTagTk","name":"meta","attribs":[{"k":"typeof","v":"mw:Annotation/tvar"},{"k":"data-mw","v":"{\"attrs\":{\"name\":\"1d\"}}"}],"dataAttribs":{"tmp":null,"tsr":[5,14]}},"test",{"type":"SelfclosingTagTk","name":"meta","attribs":[{"k":"typeof","v":"mw:Annotation/tvar/End"}],"dataAttribs":{"tmp":null,"tsr":[18,21]}}," test"],"srcOffsets":[5,5,5,26]}],"dataAttribs":{"tmp":{"tagId":null,"bits":0,"leadWS":"","trailWS":""},"tsr":[0,28],"src":"{{1x|<tvar|1d>test</> test}}"}}]

The difference is in template expansion on the MediaWiki end but probably better solved in T295834

Change 800672 had a related patch set uploaded (by Isabelle Hurbain-Palatin; author: Isabelle Hurbain-Palatin):

[mediawiki/extensions/Translate@master] Strip tvar from source when preprocessing

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

Change 800672 abandoned by Isabelle Hurbain-Palatin:

[mediawiki/extensions/Translate@master] Strip tvar from source when preprocessing

Reason:

Will split the commit to first handle parsoid tests. Also, put that in a branch.

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

Change 800759 had a related patch set uploaded (by Isabelle Hurbain-Palatin; author: Isabelle Hurbain-Palatin):

[mediawiki/extensions/Translate@master] Strip tvar from source when preprocessing

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

Change 800759 merged by jenkins-bot:

[mediawiki/extensions/Translate@master] Strip tvar from source when preprocessing

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