Page MenuHomePhabricator

Rendering error affecting only the "fragments" within internal links
Open, MediumPublicBUG REPORT

Description

This is an issue I happened to notice on zhwiki.

In page NPOV, the wikicode {{see also|#让事实自己说话}} yields the following code [[:#让事实自己说话|§ 让事实自己说话]] after preliminary parse.

In the legacy parser, the corresponding HTML link resembles <a href="#让事实自己说话">§&nbsp;让事实自己说话</a>. Even standard links navigating to other pages are presented as relative URL addresses, like <a href="/wiki/Wikipedia:%E4%B8%AD%E7%AB%8B%E7%9A%84%E8%A7%82%E7%82%B9#%E6%98%8E%E7%A1%AE%E8%A1%A8%E8%BE%BE#让事实自己说话">NPOV</a>.

In the Parsoid parser, these HTML links are converted into absolute URL paths—meaning they include both scheme and authority. Since the wikicode for these internal links consists solely of a "fragment," the rendered absolute URL lacks the page's own "path" component; consequently, the link defaults to the behavior of a pathless URL, redirecting the user to the "home page." (which like this: <a href="//zh.wikipedia.org/wiki/#让事实自己说话">NPOV</a>)

The Parsoid parser's handling of internal links consisting solely of a "fragment" needs to be fixed: either the current page name must be prepended as the URL's "path" component, or the behavior of the legacy parser—treating them as "fragment-only relative URLs"—must be maintained.

Details

Event Timeline

Restricted Application added subscribers: Stang, Aklapper. · View Herald Transcript

Easy to replicate this:

$ echo "[[:#foo]]" | MW_INSTALL_PATH=../core php bin/parse.php --integrated                                                    
...
<p data-parsoid='{"dsr":[0,9,0,0]}'><a rel="mw:WikiLink" href="./#foo" title="" data-parsoid='{"stx":"simple","a":{"href":"./#foo"},"sa":{"href":":#foo"},"dsr":[0,9,2,2]}'>#foo</a></p>

$  echo "[[#foo]]" | MW_INSTALL_PATH=../core php bin/parse.php --integrated 
...
<p data-parsoid='{"dsr":[0,8,0,0]}'><a rel="mw:WikiLink" href="./Main_Page#foo" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#foo"},"sa":{"href":"#foo"},"dsr":[0,8,2,2]}'>#foo</a></p>

This insource query on enwiki shows 300+ hits

ssastry triaged this task as Medium priority.Jul 30 2026, 5:46 PM

Something that seems at least closely related from discord:

On https://en.wikipedia.org/w/index.php?title=Wikipedia%3ANeutral_point_of_view there's a link

Wikitext: {{redirect2|Wikipedia:DUE|Wikipedia:UNDUE|guidance on balancing different aspects of a topic|#Balancing aspects}}

This generates output that includes a link with the text § Balancing aspects. With parsoid it links to https://en.wikipedia.org/wiki/#Balancing_aspects. Without it links to #Balancing_aspects.

Also mentioned at https://www.mediawiki.org/w/index.php?title=Talk%3AParsoid%2FParser_Unification%2FKnown_Issues&diff=next#Section_only_links_breaking_for_some_templates

Repeating what I said there, note that [[:]] is not a valid wikilink so it's unclear why [[:#this]] would be. [[:]] looks like it want to be a link to an empty title in the main namespace, which is why Parsoid links to a section of the empty title page, which is at least consistent.

Content-Platform-Team discussed this and considered linting away the pattern so we can bail on these fragments links as well.

Change #1339011 had a related patch set uploaded (by Arlolra; author: Arlolra):

[mediawiki/services/parsoid@master] [WIP] Colon-escaped fragment only wikilink

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