jenkins-bot has submitted this change and it was merged. Change subject: ApiFormatBase: Remove anonymous functions for PHP 5.2 compatibility ......................................................................
ApiFormatBase: Remove anonymous functions for PHP 5.2 compatibility MediaWiki 1.19 is supposed to work with PHP 5.2; however, the fix for bug 61362 ("HTML formatter for debug output from API allows HTML injection") added anonymous functions, which are a feature introduced in PHP 5.3. Follows-up 7bcbd0c635ef, which was released as part of 1.19.13. Bug: 63049 Co-Authored-By: Kevin Israel <pleasest...@live.com> Change-Id: I1641646a61700741ab9b85d16c02fad66ab2cb65 --- M RELEASE-NOTES-1.19 M includes/api/ApiFormatBase.php 2 files changed, 18 insertions(+), 10 deletions(-) Approvals: Legoktm: Looks good to me, approved jenkins-bot: Verified diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index 3935abd..7cd33a7 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -14,6 +14,8 @@ System administrators are encouraged to upgrade to this release or 1.22+ and produce a full data dump. https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Backing_up_a_wiki +* (bug 63049) Removed anonymous functions from ApiFormatBase, added in + 1.19.13 as part of the fix for bug 61362, for PHP 5.2 compatibility. == MediaWiki 1.19.20 == diff --git a/includes/api/ApiFormatBase.php b/includes/api/ApiFormatBase.php index 785fcd2..691c38f 100644 --- a/includes/api/ApiFormatBase.php +++ b/includes/api/ApiFormatBase.php @@ -33,6 +33,7 @@ private $mIsHtml, $mFormat, $mUnescapeAmps, $mHelp, $mCleared; private $mBufferResult = false, $mBuffer, $mDisabled = false; + private $mMasked; /** * Constructor @@ -275,12 +276,8 @@ } // 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 ); + $this->mMasked = array(); + $text = preg_replace_callback( '#<a .*?</a>#', array( $this, 'armorLinkCallback' ), $text ); // identify URLs $protos = wfUrlProtocolsWithoutProtRel(); @@ -288,10 +285,8 @@ $text = preg_replace( "#(($protos).*?)(")?([ \\'\"<>\n]|<|>|")#", '<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 ); + $text = preg_replace_callback( '#<([0-9a-f]{40})>#', array( $this, 'unarmorLinkCallback' ), $text ); + $this->mMasked = null; /** * Temporary fix for bad links in help messages. As a special case, @@ -306,6 +301,17 @@ return $text; } + private function armorLinkCallback( $matches ) { + $sha = sha1( $matches[0] ); + $this->mMasked[$sha] = $matches[0]; + return "<$sha>"; + } + + private function unarmorLinkCallback( $matches ) { + $sha = $matches[1]; + return isset( $this->mMasked[$sha] ) ? $this->mMasked[$sha] : $matches[0]; + } + public function getExamples() { return array( 'api.php?action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName() -- To view, visit https://gerrit.wikimedia.org/r/132912 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I1641646a61700741ab9b85d16c02fad66ab2cb65 Gerrit-PatchSet: 5 Gerrit-Project: mediawiki/core Gerrit-Branch: REL1_19 Gerrit-Owner: Kishanio <thobhanikis...@gmail.com> Gerrit-Reviewer: Anomie <bjor...@wikimedia.org> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: PleaseStand <pleasest...@live.com> Gerrit-Reviewer: Reedy <re...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits