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

Anonymous function rewritten as static one to maintain compatibility with PHP 5.2 #293

Merged
merged 1 commit into from
Mar 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions library/Zend/Xml/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ protected static function heuristicScan($xml)
}
}

/**
* @param integer $errno
* @param string $errstr
* @param string $errfile
* @param integer $errline
* @return bool
*/
protected static function _loadXmlErrorHandler($errno, $errstr, $errfile, $errline)
{
if (substr_count($errstr, 'DOMDocument::loadXML()') > 0) {
return true;
}
return false;
}

/**
* Scan XML string for potential XXE and XEE attacks
*
Expand Down Expand Up @@ -73,12 +88,8 @@ public static function scan($xml, DOMDocument $dom = null)

// Load XML with network access disabled (LIBXML_NONET)
// error disabled with @ for PHP-FPM scenario
set_error_handler(function ($errno, $errstr) {
if (substr_count($errstr, 'DOMDocument::loadXML()') > 0) {
return true;
}
return false;
}, E_WARNING);
set_error_handler(array('Zend_Xml_Security', '_loadXmlErrorHandler'), E_WARNING);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how this can possibly work if _loadXmlErrorHandler is declared with protected visibility. Going to push through an update that makes it public.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


$result = $dom->loadXml($xml, LIBXML_NONET);
restore_error_handler();

Expand Down