r12277 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r12276‎ | r12277 | r12278 >
Date:22:58, 28 December 2005
Author:vibber
Status:old
Tags:
Comment:
* (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=render
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -1410,7 +1410,7 @@
14111411 $text = $this->replaceInternalLinks($text);
14121412
14131413 # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
1414 - $s .= $prefix . preg_replace( "/\b(" . wfUrlProtocols() . ')/', "{$this->mUniqPrefix}NOPARSE$1", $this->makeImage( $nt, $text) ) . $trail;
 1414+ $s .= $prefix . $this->armorLinks( $this->makeImage( $nt, $text ) ) . $trail;
14151415 $wgLinkCache->addImageLinkObj( $nt );
14161416
14171417 wfProfileOut( "$fname-image" );
@@ -1465,11 +1465,11 @@
14661466 if( $ns == NS_MEDIA ) {
14671467 $link = $sk->makeMediaLinkObj( $nt, $text );
14681468 # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
1469 - $s .= $prefix . str_replace( 'http://', "http{$this->mUniqPrefix}NOPARSE://", $link ) . $trail;
 1469+ $s .= $prefix . $this->armorLinks( $link ) . $trail;
14701470 $wgLinkCache->addImageLinkObj( $nt );
14711471 continue;
14721472 } elseif( $ns == NS_SPECIAL ) {
1473 - $s .= $prefix . $sk->makeKnownLinkObj( $nt, $text, '', $trail );
 1473+ $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) );
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 . $sk->makeKnownLinkObj( $nt, $text, '', $trail );
 1481+ $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) );
14821482 continue;
14831483 }
14841484 }
@@ -1518,6 +1518,23 @@
15191519 }
15201520 return $retVal;
15211521 }
 1522+
 1523+ /**
 1524+ * Insert a NOPARSE hacky thing into any inline links in a chunk that's
 1525+ * going to go through further parsing steps before inline URL expansion.
 1526+ *
 1527+ * In particular this is important when using action=render, which causes
 1528+ * full URLs to be included.
 1529+ *
 1530+ * Oh man I hate our multi-layer parser!
 1531+ *
 1532+ * @param string more-or-less HTML
 1533+ * @return string less-or-more HTML with NOPARSE bits
 1534+ */
 1535+ function armorLinks( $text ) {
 1536+ return preg_replace( "/\b(" . wfUrlProtocols() . ')/',
 1537+ "{$this->mUniqPrefix}NOPARSE$1", $text );
 1538+ }
15221539
15231540 /**
15241541 * Return true if subpage links should be expanded on this page.
Index: trunk/phase3/RELEASE-NOTES
@@ -367,6 +367,7 @@
368368 * (bug 4411) Fix messages diff link for classic skin
369369 * (bug 4385) Separate parser cache entries for non-editing users, so section
370370 edit links don't vanish / appear unwanted on protected pages
 371+* (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=render
371372
372373
373374 === Caveats ===

Follow-up revisions

RevisionCommit summaryAuthorDate
r12278* (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=render...vibber00:31, 29 December 2005

Status & tagging log