r12278 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12277‎ | r12278 | r12279 >
Date:00:31, 29 December 2005
Author:vibber
Status:old
Tags:
Comment:
* (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
Modified paths:
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1469,7 +1469,7 @@
14701470 $wgLinkCache->addImageLinkObj( $nt );
14711471 continue;
14721472 } elseif( $ns == NS_SPECIAL ) {
1473 - $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) );
 1473+ $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
14741474 continue;
14751475 } elseif( $ns == NS_IMAGE ) {
14761476 $img = Image::newFromTitle( $nt );
@@ -1477,7 +1477,7 @@
14781478 // Force a blue link if the file exists; may be a remote
14791479 // upload on the shared repository, and we want to see its
14801480 // auto-generated page.
1481 - $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) );
 1481+ $s .= $this->makeKnownLinkHolder( $nt, $text, '', $trail, $prefix );
14821482 continue;
14831483 }
14841484 }
@@ -1520,6 +1520,27 @@
15211521 }
15221522
15231523 /**
 1524+ * Render a forced-blue link inline; protect against double expansion of
 1525+ * URLs if we're in a mode that prepends full URL prefixes to internal links.
 1526+ * Since this little disaster has to split off the trail text to avoid
 1527+ * breaking URLs in the following text without breaking trails on the
 1528+ * wiki links, it's been made into a horrible function.
 1529+ *
 1530+ * @param Title $nt
 1531+ * @param string $text
 1532+ * @param string $query
 1533+ * @param string $trail
 1534+ * @param string $prefix
 1535+ * @return string HTML-wikitext mix oh yuck
 1536+ */
 1537+ function makeKnownLinkHolder( $nt, $text = '', $query = '', $trail = '', $prefix = '' ) {
 1538+ list( $inside, $trail ) = Linker::splitTrail( $trail );
 1539+ $sk =& $this->mOptions->getSkin();
 1540+ $link = $sk->makeKnownLinkObj( $nt, $text, $query, $inside, $prefix );
 1541+ return $this->armorLinks( $link ) . $trail;
 1542+ }
 1543+
 1544+ /**
15241545 * Insert a NOPARSE hacky thing into any inline links in a chunk that's
15251546 * going to go through further parsing steps before inline URL expansion.
15261547 *

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r12277* (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=rendervibber22:58, 28 December 2005

Status & tagging log