Page MenuHomePhabricator

Dollar sign as first character of a Wikipedia heading produces backslash-dollar in the table of contents
Open, Needs TriagePublicBUG REPORT


While reading Wikipedia, I noticed that [ Cairns Central] had a strange \$ in its table of contents


I assumed it was a typo in the article wikitext so went to edit it to remove the backslash but found there was no blackslash in the wikitext just

==$60m Redevelopment Project==

There was no sign of any invisble characters or anything out of the ordinary. There was nothing to explain the backslash in the table of contents. I did a work-around by removing the price tag from the heading, but I cannot see what was wrong in the first place.

I experimented in various ways in but it seems any dollar sign in any place of the heading generates the backslash in the table of contents and that the following character is not the issue and you cannot escape it with backslash or another dollar sign.

What should have happened instead?:

Just put a dollar without a backslash

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Chrome is up to date
Version 125.0.6422.61 (Official Build) (64-bit)

Event Timeline

Also affects Vector, Monobook, and Timeless. Only Vector-2022 seems to be unaffected.
Additionally, the position of the dollar sign as the first character doesn't seem to matter; cf., where it has been observed in the middle of a word.

Jdlrobson subscribed.

Likely an issue in the MediaWiki parser if it impacts multiple skins.

The backslash is included in the section link so it breaks since the id at the target has no backslash.
I tried some other special characters and a backslash in a heading has the same problem: A second backslash is added in the TOC.

The section heading

== foo$ bar\ ==

produces this HTML:

<a href="#foo\$_bar\\"><span class="tocnumber">1</span> <span class="toctext">foo\$ bar\\</span></a>

Change #1034641 had a related patch set uploaded (by Vahurzpu; author: Vahurzpu):

[mediawiki/core@master] Parser: Avoid extra escaping in replaceTableOfContentsMarker

Change #1034641 merged by jenkins-bot:

[mediawiki/core@master] Parser: Avoid extra escaping in replaceTableOfContentsMarker