Skip to content
This repository was archived by the owner on May 16, 2018. It is now read-only.

Commit abc9a8e

Browse files
committed
Merge pull request #293 from mhujer/fix-anonymous-f
Fixes #292 - Anonymous function rewritten as static one to maintain compatibility with PHP 5.2
2 parents fe886c8 + ffa87ac commit abc9a8e

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

library/Zend/Xml/Security.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,21 @@ protected static function heuristicScan($xml)
4444
}
4545
}
4646

47+
/**
48+
* @param integer $errno
49+
* @param string $errstr
50+
* @param string $errfile
51+
* @param integer $errline
52+
* @return bool
53+
*/
54+
protected static function _loadXmlErrorHandler($errno, $errstr, $errfile, $errline)
55+
{
56+
if (substr_count($errstr, 'DOMDocument::loadXML()') > 0) {
57+
return true;
58+
}
59+
return false;
60+
}
61+
4762
/**
4863
* Scan XML string for potential XXE and XEE attacks
4964
*
@@ -73,12 +88,8 @@ public static function scan($xml, DOMDocument $dom = null)
7388

7489
// Load XML with network access disabled (LIBXML_NONET)
7590
// error disabled with @ for PHP-FPM scenario
76-
set_error_handler(function ($errno, $errstr) {
77-
if (substr_count($errstr, 'DOMDocument::loadXML()') > 0) {
78-
return true;
79-
}
80-
return false;
81-
}, E_WARNING);
91+
set_error_handler(array('Zend_Xml_Security', '_loadXmlErrorHandler'), E_WARNING);
92+
8293
$result = $dom->loadXml($xml, LIBXML_NONET);
8394
restore_error_handler();
8495

0 commit comments

Comments
 (0)