Page MenuHomePhabricator

Special:Interwiki allows saving interwiki URLs with trailing spaces
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Install MediaWiki 1.42 and Extension:Interwiki, and Skin:Citizen to reproduce the bug
  • Go to Special:Interwiki/add and add "example" as the prefix and "https://example.com/#$1 " as the URL
  • Add "[[example:test]]" to a page
  • Render said page using the Citizen skin

What happens?:
The URL points to https://example.com/#test%20

What should have happened instead?:
The URL should've pointed to https://example.com/#test

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

  • MediaWiki: 1.42.1 (a821a11) 07:39, 12 September 2024
  • PHP: 8.1.20 (fpm-fcgi)
  • Citizen: 2.29.0 (e3f159a) 05:51, 13 September 2024
  • Interwiki: 3.2 (9e4e73f) 06:11, 29 August 2024

Other information (browser name/version, screenshots, etc.):
Other skins do also reproduce the trailing space, but it's a literal space instead of a percent-encoded one, and thus, the bug is practically invisible on them.

Event Timeline

Change #1072877 had a related patch set uploaded (by BlankEclair; author: BlankEclair):

[mediawiki/extensions/Interwiki@master] Trim URL and API URLs when saving interwiki prefixes

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

Do you know why it affects only Citizen skin? Other skins seem to work fine

Change #1072877 merged by jenkins-bot:

[mediawiki/extensions/Interwiki@master] Trim URL and API URLs when saving interwiki prefixes

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

Change #1072926 had a related patch set uploaded (by BlankEclair; author: BlankEclair):

[mediawiki/extensions/Interwiki@REL1_42] Trim URL and API URLs when saving interwiki prefixes

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

Do you know why it affects only Citizen skin? Other skins seem to work fine

Vector and Fallback do href="https://example.com/#test ", while Citizen does href="https://example.com/#test%20". The browser appears to strip (non-encoded) whitespace from the URL when opening it, so Vector and Fallback don't exhibit the bug while Citizen does. I haven't really checked into why Citizen reformats the URL, but I believe that Citizen is technically right here.

> curl --no-progress-meter http://mw142.icecone.internal/wiki/Interwiki\?useskin={vector,fallback,citizen} | grep example.com
                <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><p><a href="https://example.com/#test " class="extiw" title="example:test">example:test</a>
                <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><p><a href="https://example.com/#test " class="extiw" title="example:test">example:test</a>
                        <div id="mw-content-text" class="mw-body-content"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr"><section class="citizen-section" id="citizen-section-0"><p><a href="https://example.com/#test%20" class="extiw" title="example:test">example:test</a>

Change #1072926 merged by jenkins-bot:

[mediawiki/extensions/Interwiki@REL1_42] Trim URL and API URLs when saving interwiki prefixes

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