From: Brion Vibber Date: Thu, 29 Dec 2005 00:31:18 +0000 (+0000) Subject: * (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=render X-Git-Tag: 1.6.0~864 X-Git-Url: http://git.cyclocoop.org/%40spipnet%40?a=commitdiff_plain;h=197d2c4d4cfe139e2373e412c9d9b02ff042c83e;p=lhc%2Fweb%2Fwiklou.git * (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=render corrected fix; was breaking urls in the trail after special links now splits and only applies the noparse on the bit inside the link --- diff --git a/includes/Parser.php b/includes/Parser.php index b356a4a63b..b921d90c9a 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -1469,7 +1469,7 @@ class Parser $wgLinkCache->addImageLinkObj( $nt ); continue; } elseif( $ns == NS_SPECIAL ) { - $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) ); + $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix ); continue; } elseif( $ns == NS_IMAGE ) { $img = Image::newFromTitle( $nt ); @@ -1477,7 +1477,7 @@ class Parser // Force a blue link if the file exists; may be a remote // upload on the shared repository, and we want to see its // auto-generated page. - $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) ); + $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix ); continue; } } @@ -1519,6 +1519,27 @@ class Parser return $retVal; } + /** + * Render a forced-blue link inline; protect against double expansion of + * URLs if we're in a mode that prepends full URL prefixes to internal links. + * Since this little disaster has to split off the trail text to avoid + * breaking URLs in the following text without breaking trails on the + * wiki links, it's been made into a horrible function. + * + * @param Title $nt + * @param string $text + * @param string $query + * @param string $trail + * @param string $prefix + * @return string HTML-wikitext mix oh yuck + */ + function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) { + list( $inside, $trail ) = Linker::splitTrail( $trail ); + $sk =& $this->mOptions->getSkin(); + $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix ); + return $this->armorLinks( $link ) . $trail; + } + /** * Insert a NOPARSE hacky thing into any inline links in a chunk that's * going to go through further parsing steps before inline URL expansion.