Page MenuHomePhabricator

Pipe trick does not work for visual edit when used in parameter
Open, Needs TriagePublicBUG REPORT

Description

List of steps to reproduce (step by step, including full links if applicable):

  • Input a link using pipe trick (e.g. [[Link (pipe trick)|]]) in a parameter to a template.
  • preview, and save the change.

What happens?:
In the preview, it works fine. But after being saved, we will see [[Link (pipe trick){{!}}]] in source code instead of [[Link (pipe trick)|Link]].

What should have happened instead?:
Links expand to [[Link (pipe trick)|Link]].

Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:

Event Timeline

Arlolra subscribed.

VE is sending [[Link (pipe trick)|]] in the data-mw.params,

<span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;1x&quot;,&quot;href&quot;:&quot;./Template:1x&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;test [[Link (pipe trick)|]]&quot;}},&quot;i&quot;:0}}]}"></span>

Since that doesn't tokenize as a link,

> echo "[[Link (pipe trick)|]]" | php bin/parse.php
<p>[[Link (pipe trick)|]]</p>

Parsoid's escapeTplArgWT escapes the pipe as {{!}} in a template param context.

This probably falls under a duplicate of T139159 in deciding where PST is supposed to happen.

I feel like this has to be guided by TemplateData: we shouldn't be trying to do PST on all arbitrary parameter data coming from VE: PST is appropriate only if the particular argument is tagged as having type="content" or type="unbalanced-wikitext" etc. And once that type is present, it's arguable that VE should be presenting a rich editing widget and handling the link as HTML, in which case the pipe trick is moot. If the user *does* want a "source editing interface" for a wikitext-type template parameter, then I think arguably it should be the client's responsibility to do the PST on that content (if that's desired; see also T139159: Pre-save transforms aren't executed on VE<->WT switch, so e.g. signatures are nowiki'ed, pipe trick links are left unresolved) rather than necessarily pushing that into Parsoid.