From 62e7d0f40aac689b56e79b504c6eb2e59cbe6c14 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 4 Apr 2021 20:21:10 -0400 Subject: [PATCH 1/2] Update HTML::purify debug comment formatting --- src/Content/Text/HTML.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index 36a926a2d..b68cbf67f 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -1003,20 +1003,19 @@ class HTML '_blank' => true, ]); - /* Uncomment to debug HTMLPurifier behavior - $config->set('Core.CollectErrors', true); - $config->set('Core.MaintainLineNumbers', true); - */ + + // Uncomment to debug HTMLPurifier behavior + //$config->set('Core.CollectErrors', true); + //$config->set('Core.MaintainLineNumbers', true); $HTMLPurifier = new \HTMLPurifier($config); $text = $HTMLPurifier->purify($text); /** @var \HTMLPurifier_ErrorCollector $errorCollector */ - /* Uncomment to debug HTML Purifier behavior - $errorCollector = $HTMLPurifier->context->get('ErrorCollector'); - var_dump($errorCollector->getRaw()); - */ + // Uncomment to debug HTML Purifier behavior + //$errorCollector = $HTMLPurifier->context->get('ErrorCollector'); + //var_dump($errorCollector->getRaw()); return $text; } From 3027b7d3aa02c40e980aacd352c88bd763663a9e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 4 Apr 2021 20:21:31 -0400 Subject: [PATCH 2/2] Prevent HTMLPurify from removing ForkAwesome icon tags --- src/Content/Text/HTML.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Content/Text/HTML.php b/src/Content/Text/HTML.php index b68cbf67f..6eb02bfbe 100644 --- a/src/Content/Text/HTML.php +++ b/src/Content/Text/HTML.php @@ -1003,6 +1003,13 @@ class HTML '_blank' => true, ]); + $config->set('AutoFormat.RemoveEmpty.Predicate', [ + 'colgroup' => [], // | + 'th' => [], // | + 'td' => [], // | + 'iframe' => ['src'], // ↳ Default HTMLPurify values + 'i' => ['class'], // Allows forkawesome icons + ]); // Uncomment to debug HTMLPurifier behavior //$config->set('Core.CollectErrors', true);