Index: branches/REL1_5/phase3/includes/Title.php |
— | — | @@ -1280,57 +1280,58 @@ |
1281 | 1281 | |
1282 | 1282 | $this->mDbkeyform = $t; |
1283 | 1283 | |
1284 | | - # Initial colon indicating main namespace |
| 1284 | + # Initial colon indicates main namespace rather than specified default |
| 1285 | + # but should not create invalid {ns,title} pairs such as {0,Project:Foo} |
1285 | 1286 | if ( ':' == $t{0} ) { |
1286 | | - $r = substr( $t, 1 ); |
1287 | 1287 | $this->mNamespace = NS_MAIN; |
1288 | | - } else { |
1289 | | - # Namespace or interwiki prefix |
1290 | | - $firstPass = true; |
1291 | | - do { |
1292 | | - if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $t, $m ) ) { |
1293 | | - $p = $m[1]; |
1294 | | - $lowerNs = strtolower( $p ); |
1295 | | - if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) { |
1296 | | - # Canonical namespace |
1297 | | - $t = $m[2]; |
1298 | | - $this->mNamespace = $ns; |
1299 | | - } elseif ( $ns = $wgContLang->getNsIndex( $lowerNs )) { |
1300 | | - # Ordinary namespace |
1301 | | - $t = $m[2]; |
1302 | | - $this->mNamespace = $ns; |
1303 | | - } elseif( $this->getInterwikiLink( $p ) ) { |
1304 | | - if( !$firstPass ) { |
1305 | | - # Can't make a local interwiki link to an interwiki link. |
1306 | | - # That's just crazy! |
| 1288 | + $t = substr( $t, 1 ); # remove the colon but continue processing |
| 1289 | + } |
| 1290 | + |
| 1291 | + # Namespace or interwiki prefix |
| 1292 | + $firstPass = true; |
| 1293 | + do { |
| 1294 | + if ( preg_match( "/^(.+?)_*:_*(.*)$/S", $t, $m ) ) { |
| 1295 | + $p = $m[1]; |
| 1296 | + $lowerNs = strtolower( $p ); |
| 1297 | + if ( $ns = Namespace::getCanonicalIndex( $lowerNs ) ) { |
| 1298 | + # Canonical namespace |
| 1299 | + $t = $m[2]; |
| 1300 | + $this->mNamespace = $ns; |
| 1301 | + } elseif ( $ns = $wgContLang->getNsIndex( $lowerNs )) { |
| 1302 | + # Ordinary namespace |
| 1303 | + $t = $m[2]; |
| 1304 | + $this->mNamespace = $ns; |
| 1305 | + } elseif( $this->getInterwikiLink( $p ) ) { |
| 1306 | + if( !$firstPass ) { |
| 1307 | + # Can't make a local interwiki link to an interwiki link. |
| 1308 | + # That's just crazy! |
| 1309 | + wfProfileOut( $fname ); |
| 1310 | + return false; |
| 1311 | + } |
| 1312 | + |
| 1313 | + # Interwiki link |
| 1314 | + $t = $m[2]; |
| 1315 | + $this->mInterwiki = $p; |
| 1316 | + |
| 1317 | + # Redundant interwiki prefix to the local wiki |
| 1318 | + if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) { |
| 1319 | + if( $t == '' ) { |
| 1320 | + # Can't have an empty self-link |
1307 | 1321 | wfProfileOut( $fname ); |
1308 | 1322 | return false; |
1309 | 1323 | } |
1310 | | - |
1311 | | - # Interwiki link |
1312 | | - $t = $m[2]; |
1313 | | - $this->mInterwiki = $p; |
1314 | | - |
1315 | | - # Redundant interwiki prefix to the local wiki |
1316 | | - if ( 0 == strcasecmp( $this->mInterwiki, $wgLocalInterwiki ) ) { |
1317 | | - if( $t == '' ) { |
1318 | | - # Can't have an empty self-link |
1319 | | - wfProfileOut( $fname ); |
1320 | | - return false; |
1321 | | - } |
1322 | | - $this->mInterwiki = ''; |
1323 | | - $firstPass = false; |
1324 | | - # Do another namespace split... |
1325 | | - continue; |
1326 | | - } |
| 1324 | + $this->mInterwiki = ''; |
| 1325 | + $firstPass = false; |
| 1326 | + # Do another namespace split... |
| 1327 | + continue; |
1327 | 1328 | } |
1328 | | - # If there's no recognized interwiki or namespace, |
1329 | | - # then let the colon expression be part of the title. |
1330 | 1329 | } |
1331 | | - break; |
1332 | | - } while( true ); |
1333 | | - $r = $t; |
1334 | | - } |
| 1330 | + # If there's no recognized interwiki or namespace, |
| 1331 | + # then let the colon expression be part of the title. |
| 1332 | + } |
| 1333 | + break; |
| 1334 | + } while( true ); |
| 1335 | + $r = $t; |
1335 | 1336 | |
1336 | 1337 | # We already know that some pages won't be in the database! |
1337 | 1338 | # |