Skip to content

Commit

Permalink
Allow the enabling of loading large files
Browse files Browse the repository at this point in the history
darylldoyle committed Feb 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent a63136c commit 5baf2f3
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
@@ -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) {

0 comments on commit 5baf2f3

Please sign in to comment.