Wiki [[_TOC_]] links are double URL-encoded for non-ASCII headings, causing anchor navigation to fail
Summary
In GitLab CE v18.9.2, TOC links generated by [[_TOC_]] are double URL-encoded for headings containing non-ASCII characters (e.g. Japanese). As a result, clicking a TOC link does not scroll to the corresponding heading.
This is a regression — the same Wiki pages worked correctly before upgrading to 18.9.2.
Steps to reproduce
- Create a Wiki page with the following content:
[[_TOC_]]
## はじめに
Some content here.
## セットアップ方法
Some content here.- Save and open the Wiki page.
- Click on a TOC link for a Japanese heading.
- Notice that the page does not scroll to the corresponding heading.
- Inspect the HTML and compare the TOC link
hrefwith the headingid.
What is the current bug behavior?
The TOC <a> tag href is double URL-encoded:
<a href="#%25E3%2581%25AF%25E3%2581%2598%25E3%2582%2581%25E3%2581%25AB">はじめに</a>The heading id and its anchor href use normal (single) URL encoding:
<h2 id="user-content-はじめに">
はじめに
<a href="#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB" class="anchor"></a>
</h2>Because the % character in the TOC link is itself percent-encoded (% → %25), the TOC link (#%25E3%25...) does not match the heading anchor (#%E3%81%...), so the browser cannot scroll to the target.
Note: headings with ASCII-only text are not affected.
What is the expected correct behavior?
The TOC link href should use single URL encoding, matching the heading anchor:
<a href="#%E3%81%AF%E3%81%98%E3%82%81%E3%81%AB">はじめに</a>Environment
- GitLab version: CE v18.9.2 (self-managed)
- Installation method: Omnibus / Docker
- Browser: Chrome 146.0.7680.165 (Official Build) (arm64)
Edited by 🤖 GitLab Bot 🤖