Class Security
Definition at line 13 of file Security.php.
◆ scan()
Security check loaded XML document
- Parameters
-
- Returns
- bool
@SuppressWarnings(PHPMD.UnusedLocalVariable)
If running with PHP-FPM we perform an heuristic scan We cannot use libxml_disable_entity_loader because of this bug
- See also
- https://bugs.php.net/bug.php?id=64938
Load XML with network access disabled (LIBXML_NONET) error disabled with @ for PHP-FPM scenario
Definition at line 44 of file Security.php.
51 if ($this->isPhpFpm()) {
52 return $this->heuristicScan($xmlContent);
55 $document =
new DOMDocument();
57 $loadEntities = libxml_disable_entity_loader(
true);
58 $useInternalXmlErrors = libxml_use_internal_errors(
true);
65 function ($errno, $errstr) {
66 if (substr_count($errstr,
'DOMDocument::loadXML()') > 0) {
74 $result = (bool)$document->loadXML($xmlContent, LIBXML_NONET);
75 restore_error_handler();
77 libxml_disable_entity_loader($loadEntities);
78 libxml_use_internal_errors($useInternalXmlErrors);
84 foreach ($document->childNodes as $child) {
85 if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
86 if ($child->entities->length > 0) {
The documentation for this class was generated from the following file: