From ed180f595d2aba11d445940b695c9959f76f1005 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Fri, 1 Jul 2016 15:51:07 -0400 Subject: [PATCH] Hack to fix #85 Signed-off-by: Edward Z. Yang --- NEWS | 2 ++ library/HTMLPurifier/Injector/RemoveEmpty.php | 6 ++++++ library/HTMLPurifier/Printer/ConfigForm.php | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 7fdc3e0a..a93723f9 100644 --- a/NEWS +++ b/NEWS @@ -36,6 +36,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier - Don't match for inside comments with %Core.ConvertDocumentToFragment. (#67) - SafeObject is now less case sensitive. (#57) +- AutoFormat.RemoveEmpty.Predicate now correctly renders in + web form. (#85) 4.7.0, released 2015-08-04 # opacity is now considered a "tricky" CSS property rather than a diff --git a/library/HTMLPurifier/Injector/RemoveEmpty.php b/library/HTMLPurifier/Injector/RemoveEmpty.php index 01353ff1..0ebc477c 100644 --- a/library/HTMLPurifier/Injector/RemoveEmpty.php +++ b/library/HTMLPurifier/Injector/RemoveEmpty.php @@ -46,6 +46,12 @@ class HTMLPurifier_Injector_RemoveEmpty extends HTMLPurifier_Injector $this->removeNbsp = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp'); $this->removeNbspExceptions = $config->get('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions'); $this->exclude = $config->get('AutoFormat.RemoveEmpty.Predicate'); + foreach ($this->exclude as $key => $attrs) { + if (!is_array($attrs)) { + // HACK, see HTMLPurifier/Printer/ConfigForm.php + $this->exclude[$key] = explode(';', $attrs); + } + } $this->attrValidator = new HTMLPurifier_AttrValidator(); } diff --git a/library/HTMLPurifier/Printer/ConfigForm.php b/library/HTMLPurifier/Printer/ConfigForm.php index 36100ce7..65a77790 100644 --- a/library/HTMLPurifier/Printer/ConfigForm.php +++ b/library/HTMLPurifier/Printer/ConfigForm.php @@ -327,6 +327,10 @@ class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer case HTMLPurifier_VarParser::HASH: $nvalue = ''; foreach ($value as $i => $v) { + if (is_array($v)) { + // HACK + $v = implode(";", $v); + } $nvalue .= "$i:$v" . PHP_EOL; } $value = $nvalue; -- 2.11.4.GIT