File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments