Page MenuHomePhabricator

Call to template can duplicate ref tag contents when using <h3>
Closed, ResolvedPublic

Description

This look like specific to h3 tag, code like <h3 id="{{{1}}}">{{{1}}}</h3> in a template will duplicate a ref if {{{1}}} contains one. If I replace h3 by a span the ref is no longer duplicated

see https://fr.wikisource.org/wiki/Utilisateur:Phe/Test15 and https://fr.wikisource.org/wiki/Utilisateur:Phe/Test16

User reporting this trouble said it was working in the past.

Event Timeline

Phe raised the priority of this task from to Needs Triage.
Phe updated the task description. (Show Details)
Phe added a subscriber: Phe.
Aklapper renamed this task from Call to template can duplicate ref tag contents. to Call to template can duplicate ref tag contents when using <h3>.May 21 2015, 11:00 AM
Aklapper triaged this task as Low priority.
Aklapper set Security to None.

This is indeed new, caused by I0e136f952302b65f1abeeac5273bd842867e1dac. I don't consider this a big deal though, since something that contains a reference should never be used as an element's id anyway.

What I showed above is a simplified test case, the template code is id="{{anchorencode:{{{1}}}}}" so it didn't break whatsoever was passed as {{{1}}}, we have around around 50k use of that template on fr.wikisource.org and ref in title are not so rare like here : https://fr.wikisource.org/wiki/Page:Helv%C3%A9tius_-_%C5%92uvres_compl%C3%A8tes_d%E2%80%99Helv%C3%A9tius,_tome_6.djvu/3

Where is the documentation in mediawiki-core explaining that == foo<ref>bar</ref> == is disallowed as the above patch seems to break it too ? see https://fr.wikisource.org/wiki/Utilisateur:Phe/Test17

Jackmcbarn raised the priority of this task from Low to Medium.May 22 2015, 4:23 AM

That one is a much better example of the issue. It definitely needs a fix.

I see what needs to be done here. I'll get a fix written tomorrow.

Okay, this is trickier than I thought. The problem is that the easy way of fixing this will result in this breaking:

Template:Foo:
Something{{{1}}}. Something else{{{1}}}.

Some page:
{{foo|<ref>The reference</ref>}}

Specifically, a naïve fix will result in both of those elements having the same ID, and only one backlink being generated.

Change 213313 had a related patch set uploaded (by Jackmcbarn):
Don't run references if the output type isn't HTML

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

Change 213313 merged by jenkins-bot:
Don't run references if the output type isn't HTML

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

The fix is part of 1.26wmf8, which will be deployed to all WMF wikis by June 3rd.

Also seems to be affecting refs that are added into the alt attribute of inline images.