From 41106688abbe6dfff61c5642924ced42af3f0d33 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 12 Jul 2019 12:13:33 +0200 Subject: [PATCH] RedirectSpecialPage: handle interwiki redirects. Previously, WikiPage::performRequest() would assume that Titles returned by RedirectSpecialPage::getRedirect() are local pages, and would set $wgTitle to whatever was returned. That would lead to a confused state where the skin would try to render for an interwiki Title. Instead, WikiPage::performRequest() should wrap the interwiki redirect in a call to Special:GoToInterwiki/xyz, just like Title::getFullUrlForRedirect() does, but still avoid the HTTP redirect, to avoid leaking private information via view counters (T109724). There are two things to test: 1) call Special:MyLanguage with an interwiki prefix, e.g. Special:MyLanguage/wikipedia:XYZ. 2) create a page that contains an interwiki redirect, e.g. #REDIRECT [[wikipedia:XYZ]], then call Special:MyLanguage for that page. For these tests, the user language should be the same as the content language. That is the critical case. If the user language differs from the content language, the problem would be obscured by another bug which is addressed by Ib4cbeec47a877c473. Bug: T227700 Change-Id: I2852c5a9774f0c76e49f1e3876fcfe85a305f9ce --- includes/MediaWiki.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/MediaWiki.php b/includes/MediaWiki.php index 69f23c1d13..3934cd2aa8 100644 --- a/includes/MediaWiki.php +++ b/includes/MediaWiki.php @@ -260,8 +260,16 @@ class MediaWiki { ) { list( , $subpage ) = $spFactory->resolveAlias( $title->getDBkey() ); $target = $specialPage->getRedirect( $subpage ); - // target can also be true. We let that case fall through to normal processing. + // Target can also be true. We let that case fall through to normal processing. if ( $target instanceof Title ) { + if ( $target->isExternal() ) { + // Handle interwiki redirects + $target = SpecialPage::getTitleFor( + 'GoToInterwiki', + $target->getPrefixedDBkey() + ); + } + $query = $specialPage->getRedirectQuery( $subpage ) ?: []; $request = new DerivativeRequest( $this->context->getRequest(), $query ); $request->setRequestURL( $this->context->getRequest()->getRequestURL() ); -- 2.20.1