Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 9fe5103

Browse files
ezimuelweierophinney
authored andcommitted
Fix for potential XXE/XEE attacks on XML
1 parent 184be92 commit 9fe5103

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Diff for: src/Json.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use SimpleXMLElement;
1313
use Zend\Json\Exception\RecursionException;
1414
use Zend\Json\Exception\RuntimeException;
15+
use Zend\Xml\Security as XmlSecurity;
1516

1617
/**
1718
* Class for encoding to and decoding from JSON.
@@ -311,10 +312,10 @@ protected static function _processXml($simpleXmlElementObject, $ignoreXmlAttribu
311312
public static function fromXml($xmlStringContents, $ignoreXmlAttributes = true)
312313
{
313314
// Load the XML formatted string into a Simple XML Element object.
314-
$simpleXmlElementObject = simplexml_load_string($xmlStringContents);
315+
$simpleXmlElementObject = XmlSecurity::scan($xmlStringContents);
315316

316317
// If it is not a valid XML content, throw an exception.
317-
if ($simpleXmlElementObject == null) {
318+
if (!$simpleXmlElementObject) {
318319
throw new RuntimeException('Function fromXml was called with an invalid XML formatted string.');
319320
} // End of if ($simpleXmlElementObject == null)
320321

0 commit comments

Comments
 (0)