Allow additional interwiki prefixes on local interwiki links
authorThis, that and the other <at.light@live.com.au>
Sat, 15 Feb 2014 00:22:25 +0000 (11:22 +1100)
committerThis, that and the other <at.light@live.com.au>
Sat, 5 Apr 2014 02:34:34 +0000 (13:34 +1100)
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
tests/phpunit/includes/TitleTest.php

index 878f95d..6c56ba6 100644 (file)
@@ -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;
index a332368..6a117e6 100644 (file)
@@ -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" );
                }