mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
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:
commit
07ddd9fdae
@ -649,8 +649,10 @@ class Comment extends DataObject
|
||||
*/
|
||||
public function purifyHtml($dirtyHtml)
|
||||
{
|
||||
$purifier = $this->getHtmlPurifierService();
|
||||
return $purifier->purify($dirtyHtml);
|
||||
if ($service = $this->getHtmlPurifierService()) {
|
||||
return $service->purify($dirtyHtml);
|
||||
}
|
||||
return $dirtyHtml;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -658,6 +660,10 @@ class Comment extends DataObject
|
||||
*/
|
||||
public function getHtmlPurifierService()
|
||||
{
|
||||
if (!class_exists('HTMLPurifier_Config')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$allowedElements = $this->getOption('html_allowed_elements');
|
||||
$config->set('HTML.AllowedElements', $allowedElements);
|
||||
|
Loading…
Reference in New Issue
Block a user