$link = $origLink;
}
- $noforce = ( substr( $origLink, 0, 1 ) !== ':' );
- if ( !$noforce ) {
- # Strip off leading ':'
- $link = substr( $link, 1 );
- }
-
$unstrip = $this->mStripState->unstripNoWiki( $link );
$nt = is_string( $unstrip ) ? Title::newFromText( $unstrip ) : null;
if ( $nt === null ) {
$ns = $nt->getNamespace();
$iw = $nt->getInterwiki();
+ $noforce = ( substr( $origLink, 0, 1 ) !== ':' );
+
if ( $might_be_img ) { # if this is actually an invalid link
if ( $ns == NS_FILE && $noforce ) { # but might be an image
$found = false;
$wasblank = ( $text == '' );
if ( $wasblank ) {
$text = $link;
+ if ( !$noforce ) {
+ # Strip off leading ':'
+ $text = substr( $text, 1 );
+ }
} else {
# T6598 madness. Handle the quotes only if they come from the alternate part
# [[Lista d''e paise d''o munno]] -> <a href="...">Lista d''e paise d''o munno</a>
}
$s = rtrim( $s . $prefix );
- $s .= trim( $trail, "\n" ) == '' ? '': $prefix . $trail;
+ $s .= trim( $trail, "\n" ) == '' ? '' : $prefix . $trail;
continue;
}
# Initial colon indicates main namespace rather than specified default
# but should not create invalid {ns,title} pairs such as {0,Project:Foo}
- if ( $dbkey !== '' && ':' == $dbkey[0] ) {
+ if ( $dbkey !== '' && $dbkey[0] == ':' ) {
$parts['namespace'] = NS_MAIN;
$dbkey = substr( $dbkey, 1 ); # remove the colon but continue processing
$dbkey = trim( $dbkey, '_' ); # remove any subsequent whitespace
if ( $dbkey !== '' && $dbkey[0] == ':' ) {
$parts['namespace'] = NS_MAIN;
$dbkey = substr( $dbkey, 1 );
+ $dbkey = trim( $dbkey, '_' );
}
}
# If there's no recognized interwiki or namespace,
<a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
!! end
+!! test
+Multiple colons escaping interlanguage links
+!! wikitext
+[[:es:Spanish]]
+[[::es:Spanish]]
+[[:::es:Spanish]]
+!! html/php
+<p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
+[[::es:Spanish]]
+[[:::es:Spanish]]
+</p>
+!! end
+
## parsoid html2wt will normalize the space to _
!! test
Space and question mark encoding in interlanguage links (T95473)