Skip to content

Commit

Permalink
Merge pull request #98 from darylldoyle/feature/load-huge-files
Browse files Browse the repository at this point in the history
Allow the enabling of loading large files
  • Loading branch information
darylldoyle authored Feb 22, 2024
2 parents a1af5cd + 5baf2f3 commit 6a2c069
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ class Sanitizer
*/
protected $useNestingLimit = 15;

/**
* @var bool
*/
protected $allowHugeFiles = false;

/**
*
*/
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 6a2c069

Please sign in to comment.