Skip to content

Commit

Permalink
Merge pull request #89 from ohader/reject/CVE-2023-28426
Browse files Browse the repository at this point in the history
Revert changes introduced for GHSA-xrqq-wqh4-5hg2 (CVE-2023-28426)
  • Loading branch information
darylldoyle committed Jul 18, 2023
2 parents 239e257 + 3729690 commit e42eadd
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 20 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"require": {
"ext-dom": "*",
"ext-libxml": "*",
"php": "^5.6 || ^7.0 || ^8.0",
"ezyang/htmlpurifier": "^4.16"
"php": "^5.6 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.5 || ^8.5"
Expand Down
6 changes: 1 addition & 5 deletions src/Sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
use enshrined\svgSanitize\data\TagInterface;
use enshrined\svgSanitize\data\XPath;
use enshrined\svgSanitize\ElementReference\Resolver;
use HTMLPurifier;
use HTMLPurifier_Config;

/**
* Class Sanitizer
Expand Down Expand Up @@ -648,9 +646,7 @@ public function setUseNestingLimit($limit)
protected function cleanUnsafeNodes(\DOMNode $currentElement) {
// Replace CDATA node with encoded text node
if ($currentElement instanceof \DOMCdataSection) {
$purifier = new HTMLPurifier(HTMLPurifier_Config::createDefault());
$clean_html = $purifier->purify($currentElement->nodeValue);
$textNode = $currentElement->ownerDocument->createTextNode($clean_html);
$textNode = $currentElement->ownerDocument->createTextNode($currentElement->nodeValue);
$currentElement->parentNode->replaceChild($textNode, $currentElement);
// If the element doesn't have a tagname, remove it and continue with next iteration
} elseif (!$currentElement instanceof \DOMElement && !$currentElement instanceof \DOMText) {
Expand Down
9 changes: 4 additions & 5 deletions tests/data/cdataClean.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions tests/data/cdataTwoClean.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tests/data/formDataClean.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions tests/data/htmlClean.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e42eadd

Please sign in to comment.