From 8dc36df7a464a984d60762cd8dd343a10cf30c47 Mon Sep 17 00:00:00 2001 From: Gordon Anderson Date: Tue, 12 Jan 2016 00:02:08 +0700 Subject: [PATCH] FIX: The AutoFormat.AutoParagraph injector of HTMLPurifier fails if the p tag is not allowed. Make a check for this --- code/model/Comment.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/code/model/Comment.php b/code/model/Comment.php index 09e0825..9c301c5 100755 --- a/code/model/Comment.php +++ b/code/model/Comment.php @@ -619,8 +619,14 @@ class Comment extends DataObject { */ public function getHtmlPurifierService() { $config = HTMLPurifier_Config::createDefault(); - $config->set('HTML.AllowedElements', $this->getOption('html_allowed_elements')); - $config->set('AutoFormat.AutoParagraph', true); + $allowedElements = $this->getOption('html_allowed_elements'); + $config->set('HTML.AllowedElements', $allowedElements); + + // This injector cannot be set unless the 'p' element is allowed + if (in_array('p', $allowedElements)) { + $config->set('AutoFormat.AutoParagraph', true); + } + $config->set('AutoFormat.Linkify', true); $config->set('URI.DisableExternalResources', true); $config->set('Cache.SerializerPath', getTempFolder());