summaryrefslogtreecommitdiff
path: root/includes/api
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2014-02-28 08:36:29 +0100
committerPierre Schmitz <pierre@archlinux.de>2014-02-28 08:36:29 +0100
commita4edbfa031eb4cd72678051f1510afde4f77951e (patch)
tree76cef11b1a13538c8982a7491dbbf7324d4a7b2a /includes/api
parent1b65fa2a5f4c48b02ceda934e9c1aee2d03ce453 (diff)
Update to MediaWiki 1.22.3
Diffstat (limited to 'includes/api')
-rw-r--r--includes/api/ApiFormatBase.php18
1 files changed, 17 insertions, 1 deletions
diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php
index b89fb3a7..70495439 100644
--- a/includes/api/ApiFormatBase.php
+++ b/includes/api/ApiFormatBase.php
@@ -272,17 +272,33 @@ See the <a href='https://www.mediawiki.org/wiki/API'>complete documentation</a>,
// encode all comments or tags as safe blue strings
$text = str_replace( '&lt;', '<span style="color:blue;">&lt;', $text );
$text = str_replace( '&gt;', '&gt;</span>', $text );
+
// identify requests to api.php
- $text = preg_replace( "#api\\.php\\?[^ <\n\t]+#", '<a href="\\0">\\0</a>', $text );
+ $text = preg_replace( '#^(\s*)(api\.php\?[^ <\n\t]+)$#m', '\1<a href="\2">\2</a>', $text );
if ( $this->mHelp ) {
// make strings inside * bold
$text = preg_replace( "#\\*[^<>\n]+\\*#", '<b>\\0</b>', $text );
}
+
+ // Armor links (bug 61362)
+ $masked = array();
+ $text = preg_replace_callback( '#<a .*?</a>#', function ( $matches ) use ( &$masked ) {
+ $sha = sha1( $matches[0] );
+ $masked[$sha] = $matches[0];
+ return "<$sha>";
+ }, $text );
+
// identify URLs
$protos = wfUrlProtocolsWithoutProtRel();
// This regex hacks around bug 13218 (&quot; included in the URL)
$text = preg_replace( "#(((?i)$protos).*?)(&quot;)?([ \\'\"<>\n]|&lt;|&gt;|&quot;)#", '<a href="\\1">\\1</a>\\3\\4', $text );
+ // Unarmor links
+ $text = preg_replace_callback( '#<([0-9a-f]{40})>#', function ( $matches ) use ( &$masked ) {
+ $sha = $matches[1];
+ return isset( $masked[$sha] ) ? $masked[$sha] : $matches[0];
+ }, $text );
+
/**
* Temporary fix for bad links in help messages. As a special case,
* XML-escaped metachars are de-escaped one level in the help message