Index: trunk/phase3/includes/Parser.php |
— | — | @@ -1410,7 +1410,7 @@ |
1411 | 1411 | $text = $this->replaceInternalLinks($text); |
1412 | 1412 | |
1413 | 1413 | # 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; |
1415 | 1415 | $wgLinkCache->addImageLinkObj( $nt ); |
1416 | 1416 | |
1417 | 1417 | wfProfileOut( "$fname-image" ); |
— | — | @@ -1465,11 +1465,11 @@ |
1466 | 1466 | if( $ns == NS_MEDIA ) { |
1467 | 1467 | $link = $sk->makeMediaLinkObj( $nt, $text ); |
1468 | 1468 | # 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; |
1470 | 1470 | $wgLinkCache->addImageLinkObj( $nt ); |
1471 | 1471 | continue; |
1472 | 1472 | } elseif( $ns == NS_SPECIAL ) { |
1473 | | - $s .= $prefix . $sk->makeKnownLinkObj( $nt, $text, '', $trail ); |
| 1473 | + $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) ); |
1474 | 1474 | continue; |
1475 | 1475 | } elseif( $ns == NS_IMAGE ) { |
1476 | 1476 | $img = Image::newFromTitle( $nt ); |
— | — | @@ -1477,7 +1477,7 @@ |
1478 | 1478 | // Force a blue link if the file exists; may be a remote |
1479 | 1479 | // upload on the shared repository, and we want to see its |
1480 | 1480 | // auto-generated page. |
1481 | | - $s .= $prefix . $sk->makeKnownLinkObj( $nt, $text, '', $trail ); |
| 1481 | + $s .= $prefix . $this->armorLinks( $sk->makeKnownLinkObj( $nt, $text, '', $trail ) ); |
1482 | 1482 | continue; |
1483 | 1483 | } |
1484 | 1484 | } |
— | — | @@ -1518,6 +1518,23 @@ |
1519 | 1519 | } |
1520 | 1520 | return $retVal; |
1521 | 1521 | } |
| 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 | + } |
1522 | 1539 | |
1523 | 1540 | /** |
1524 | 1541 | * Return true if subpage links should be expanded on this page. |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -367,6 +367,7 @@ |
368 | 368 | * (bug 4411) Fix messages diff link for classic skin |
369 | 369 | * (bug 4385) Separate parser cache entries for non-editing users, so section |
370 | 370 | edit links don't vanish / appear unwanted on protected pages |
| 371 | +* (bug 2726, 3397) Fix [[Special:]] and [[:Image]] links in action=render |
371 | 372 | |
372 | 373 | |
373 | 374 | === Caveats === |