From 5461fd3f2847f455d9db3f3d2887379691557e40 Mon Sep 17 00:00:00 2001 From: "This, that and the other" Date: Sat, 15 Feb 2014 11:22:25 +1100 Subject: [PATCH] Allow additional interwiki prefixes on local interwiki links This code was added by Brion back in 2004 as part of r6398. According to Brion, links like [[en:wikt:foo]] on English Wikipedia are "just crazy!", but I can't see any reason to disallow them. Bug: 61357 Change-Id: If449e60a0ef95cfe3dd6f4b1809ac012be62a0ea --- includes/title/MediaWikiTitleCodec.php | 9 --------- tests/phpunit/includes/TitleTest.php | 4 +++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/includes/title/MediaWikiTitleCodec.php b/includes/title/MediaWikiTitleCodec.php index 878f95d5e8..6c56ba6b52 100644 --- a/includes/title/MediaWikiTitleCodec.php +++ b/includes/title/MediaWikiTitleCodec.php @@ -242,7 +242,6 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { } # Namespace or interwiki prefix - $firstPass = true; $prefixRegexp = "/^(.+?)_*:_*(.*)$/S"; do { $m = array(); @@ -264,13 +263,6 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { } } } elseif ( Interwiki::isValidInterwiki( $p ) ) { - if ( !$firstPass ) { - //TODO: get rid of global state! - # Can't make a local interwiki link to an interwiki link. - # That's just crazy! - throw new MalformedTitleException( 'Interwiki prefix found in title: ' . $text ); - } - # Interwiki link $dbkey = $m[2]; $parts['interwiki'] = $this->language->lc( $p ); @@ -283,7 +275,6 @@ class MediaWikiTitleCodec implements TitleFormatter, TitleParser { throw new MalformedTitleException( 'Local interwiki with empty title: ' . $text ); } $parts['interwiki'] = ''; - $firstPass = false; # Do another namespace split... continue 2; diff --git a/tests/phpunit/includes/TitleTest.php b/tests/phpunit/includes/TitleTest.php index a332368e00..6a117e6835 100644 --- a/tests/phpunit/includes/TitleTest.php +++ b/tests/phpunit/includes/TitleTest.php @@ -87,7 +87,9 @@ class TitleTest extends MediaWikiTestCase { 'remotetestiw: Talk: # anchor', 'remotetestiw: #bar', 'remotetestiw: Talk:', - 'remotetestiw: Talk: Foo' + 'remotetestiw: Talk: Foo', + 'localtestiw:remotetestiw:', + 'localtestiw:remotetestiw:foo' ) as $text ) { $this->assertInstanceOf( 'Title', Title::newFromText( $text ), "Valid: $text" ); } -- 2.20.1