Skip to content

Commit

Permalink
[BUGFIX] Remove doctype after node elements have been analyzed
Browse files Browse the repository at this point in the history
  • Loading branch information
ohader committed Jul 15, 2021
1 parent feff971 commit 1dd4467
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ public function sanitize($dirty)
return false;
}

$this->removeDoctype();

// Pre-process all identified elements
$xPath = new XPath($this->xmlDocument);
$this->elementReferenceResolver = new Resolver($xPath, $this->useNestingLimit);
Expand All @@ -219,6 +217,8 @@ public function sanitize($dirty)
// Grab all the elements
$allElements = $this->xmlDocument->getElementsByTagName("*");

// remove doctype after node elements have been analyzed
$this->removeDoctype();
// Start the cleaning proccess
$this->startClean($allElements, $elementsToRemove);

Expand Down
3 changes: 2 additions & 1 deletion tests/SanitizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,10 @@ public function doctypeAndEntityAreRemoved()
$expected = file_get_contents($dataDirectory . '/entityClean.svg');

$this->class->minify(false);
$this->class->removeRemoteReferences(true);
$cleanData = $this->class->sanitize($initialData);

$this->assertXmlStringEqualsXmlString($expected, $cleanData);
self::assertSame($expected, $cleanData);
}

/**
Expand Down

0 comments on commit 1dd4467

Please sign in to comment.