diff --git a/src/Sanitizer.php b/src/Sanitizer.php index b5d6dfe..60072fa 100644 --- a/src/Sanitizer.php +++ b/src/Sanitizer.php @@ -81,6 +81,11 @@ class Sanitizer */ protected $useNestingLimit = 15; + /** + * @var bool + */ + protected $allowHugeFiles = false; + /** * */ @@ -183,6 +188,24 @@ public function getXmlIssues() { return $this->xmlIssues; } + /** + * Can we allow huge files? + * + * @return bool + */ + public function getAllowHugeFiles() { + return $this->allowHugeFiles; + } + + /** + * Set whether we can allow huge files. + * + * @param bool $allowHugeFiles + */ + public function setAllowHugeFiles( $allowHugeFiles ) { + $this->allowHugeFiles = $allowHugeFiles; + } + /** * Sanitize the passed string @@ -203,7 +226,7 @@ public function sanitize($dirty) $this->resetInternal(); $this->setUpBefore(); - $loaded = $this->xmlDocument->loadXML($dirty); + $loaded = $this->xmlDocument->loadXML($dirty, $this->getAllowHugeFiles() ? LIBXML_PARSEHUGE : 0); // If we couldn't parse the XML then we go no further. Reset and return false if (!$loaded) {