|
|
@@ -92,7 +92,9 @@ class Xml
|
|
|
* - `readFile` Set to false to disable file reading. This is important to disable when
|
|
|
* putting user data into Xml::build(). If enabled local files will be read if they exist.
|
|
|
* Defaults to true for backwards compatibility reasons.
|
|
|
- * - If using array as input, you can pass `options` from Xml::fromArray.
|
|
|
+ * - `parseHuge` Enable the `LIBXML_PARSEHUGE` flag.
|
|
|
+ *
|
|
|
+ * If using array as input, you can pass `options` from Xml::fromArray.
|
|
|
*
|
|
|
* @param string|array $input XML string, a path to a file, a URL or an array
|
|
|
* @param string|array $options The options to use
|
|
|
@@ -104,7 +106,8 @@ class Xml
|
|
|
$defaults = [
|
|
|
'return' => 'simplexml',
|
|
|
'loadEntities' => false,
|
|
|
- 'readFile' => true
|
|
|
+ 'readFile' => true,
|
|
|
+ 'parseHuge' => true,
|
|
|
];
|
|
|
$options += $defaults;
|
|
|
|
|
|
@@ -142,9 +145,13 @@ class Xml
|
|
|
if ($hasDisable && !$options['loadEntities']) {
|
|
|
libxml_disable_entity_loader(true);
|
|
|
}
|
|
|
+ $flags = LIBXML_NOCDATA;
|
|
|
+ if (!empty($options['parseHuge'])) {
|
|
|
+ $flags |= LIBXML_PARSEHUGE;
|
|
|
+ }
|
|
|
try {
|
|
|
if ($options['return'] === 'simplexml' || $options['return'] === 'simplexmlelement') {
|
|
|
- $xml = new SimpleXMLElement($input, LIBXML_NOCDATA);
|
|
|
+ $xml = new SimpleXMLElement($input, $flags);
|
|
|
} else {
|
|
|
$xml = new DOMDocument();
|
|
|
$xml->loadXML($input);
|