Page MenuHomePhabricator

Having <> in headings leads to errors
Closed, ResolvedPublicBUG REPORT

Description

Step to replicate the issue:
Go to permalink

What happens?:
Heading is

"data-mw-fallback-anchor="Conflict_of_interest_management:_Arbitrators.27_opinion_on_hearing_this_matter_.3C0.2F0.2F1.3E" data-mw-thread-id="h-Conflict_of_interest_management:_Arbitrators'_opinion_on_hearing_this_matter_<0/-Conflict_of_interest_management-20240229095400">Conflict of interest management: Arbitrators' opinion on hearing this matter <0/0/1>

What should have happened instead?:
Heading should have been "Conflict of interest management: Arbitrators' opinion on hearing this matter <0/0/1>"

Event Timeline

matmarex subscribed.

Looks like the bug only affects pages with DiscussionTools (not main namespace). It's actually the > by itself which triggers the problem. It's probably somehow caused by rMW834ff25dc1ab: Move section heading formatting to post-cache transform (take 2).

This happens because DiscussionTools's CommentFormatter, and MediaWiki core's HandleSectionLinks, expect different HTML serialization.

Input from Parser to CommentFormatter looks like this: (given the wikitext == a > ==)

html
<h2 data-mw-anchor="a_&gt;" data-mw-fallback-anchor="a_.3E">a &gt;<mw:editsection page="Talk:T358810" section="1">a &gt;</mw:editsection></h2>

The output from CommentFormatter, input to HandleSectionLinks, looks like this:

html
<div class="mw-heading mw-heading2 ext-discussiontools-init-section"><h2 data-mw-anchor="a_>" data-mw-fallback-anchor="a_.3E" data-mw-thread-id="h-a_>"><span data-mw-comment-start="" id="h-a_>"></span>a ><mw:editsection page="Talk:T358810" section="1">a ></mw:editsection><span data-mw-comment-end="h-a_>"></span></h2><!--__DTELLIPSISBUTTON__{"threadItem":{"headingLevel":2,"name":"h-","type":"heading","level":0,"id":"h-a_&gt;","replies":[]}}--></div>

Note that data-mw-anchor="a_&gt;" became data-mw-anchor="a_>". Both forms are valid, but HandleSectionLinks has a regexp that incorrectly matches the second one: https://gerrit.wikimedia.org/g/mediawiki/core/+/90f409259d311073d8deafecdcb2f48fddffe179/includes/OutputTransform/Stages/HandleSectionLinks.php#25

Change 1007962 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] HandleSectionLinks: Improve HEADING_REGEX

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

Shot: https://commons.wikimedia.org/w/index.php?title=File:Bug-in-subheadings-ASCII-62.png
Link: https://eo.wikipedia.org/w/index.php?title=Vikipedio:Alinomendaj_artikoloj&oldid=8650474#Adolf_Hitler_%E2%86%92_Adolfo_Hitlero_kaj_Vladimir_Putin_%E2%86%92_Vladimiro_Putino

Introduced recently and visible on Esperanto wikipedia and Indonesian wikipedia, but not (yet) on Swedish wiktionary. The greater-than sign > breaks wiki subheadings. The less-than sign surprisignly does not have the same effect.

Change 1008472 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@wmf/1.42.0-wmf.20] HandleSectionLinks: Fix handling headings with raw `>` in attributes

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

Change 1007962 merged by jenkins-bot:

[mediawiki/core@master] HandleSectionLinks: Fix handling headings with raw `>` in attributes

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

I'm sorry everyone, I wanted to backport this fix yesterday, but the deployment window has been cancelled due to problems with the platform (T359155), and the same thing happened when I tried again this afternoon. I'll try again when the problems are resolved.

Change 1008472 merged by jenkins-bot:

[mediawiki/core@wmf/1.42.0-wmf.20] HandleSectionLinks: Fix handling headings with raw `>` in attributes

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

Mentioned in SAL (#wikimedia-operations) [2024-03-05T21:26:31Z] <urbanecm@deploy2002> Started scap: Backport for [[gerrit:1008765|Set background/color to inherit for common templates in dark mode (T358164)]], [[gerrit:1008472|HandleSectionLinks: Fix handling headings with raw > in attributes (T358810)]]

Mentioned in SAL (#wikimedia-operations) [2024-03-05T21:28:01Z] <urbanecm@deploy2002> matmarex and jdlrobson and urbanecm: Backport for [[gerrit:1008765|Set background/color to inherit for common templates in dark mode (T358164)]], [[gerrit:1008472|HandleSectionLinks: Fix handling headings with raw > in attributes (T358810)]] synced to the testservers (https://wikitech.wikimedia.org/wiki/Mwdebug)

Mentioned in SAL (#wikimedia-operations) [2024-03-05T21:42:21Z] <urbanecm@deploy2002> Finished scap: Backport for [[gerrit:1008765|Set background/color to inherit for common templates in dark mode (T358164)]], [[gerrit:1008472|HandleSectionLinks: Fix handling headings with raw > in attributes (T358810)]] (duration: 15m 50s)

Just in case you need another test case :) https://commons.wikimedia.org/w/index.php?title=Module_talk:POTY&oldid=857148097 (<nowiki><ul></nowiki>)

This one’s looking good now (after a manual purge), thanks for your perseverance in deploying the fix!

Deployed to all wikis, looks fixed.