Merge pull request #236 from creative-commoners/pulls/2.1/unbreak-cleaning

FIX backport fix for lack of HTMLPurifier breakage
This commit is contained in:
Robbie Averill 2018-03-12 10:48:26 +13:00 committed by GitHub
commit 07ddd9fdae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -649,8 +649,10 @@ class Comment extends DataObject
*/ */
public function purifyHtml($dirtyHtml) public function purifyHtml($dirtyHtml)
{ {
$purifier = $this->getHtmlPurifierService(); if ($service = $this->getHtmlPurifierService()) {
return $purifier->purify($dirtyHtml); return $service->purify($dirtyHtml);
}
return $dirtyHtml;
} }
/** /**
@ -658,6 +660,10 @@ class Comment extends DataObject
*/ */
public function getHtmlPurifierService() public function getHtmlPurifierService()
{ {
if (!class_exists('HTMLPurifier_Config')) {
return null;
}
$config = HTMLPurifier_Config::createDefault(); $config = HTMLPurifier_Config::createDefault();
$allowedElements = $this->getOption('html_allowed_elements'); $allowedElements = $this->getOption('html_allowed_elements');
$config->set('HTML.AllowedElements', $allowedElements); $config->set('HTML.AllowedElements', $allowedElements);