Welcome! » Log In » Create A New Profile

PHP < 5.4 Compatibility

Posted by GromNaN 
PHP < 5.4 Compatibility
October 22, 2013 05:33AM


The master of HTML Purifier is not compatible with PHP < 5.4 since this commit : http://repo.or.cz/w/htmlpurifier.git/commit/8f401f769ec781b68550a142fc7a04dedc809eeb?f=library/HTMLPurifier/Strategy/MakeWellFormed.php

On line 585 of library/HTMLPurifier/Strategy/MakeWellFormed.php, the code use "dereferenced array". http://repo.or.cz/w/htmlpurifier.git/blob/HEAD:/library/HTMLPurifier/Strategy/MakeWellFormed.php#l585

Here is a patch that can be applied to solve this issue:

diff --git a/library/HTMLPurifier/Strategy/MakeWellFormed.php b/library/HTMLPurifier/Strategy/MakeWellFormed.php
index f844d45..e389e00 100644
--- a/library/HTMLPurifier/Strategy/MakeWellFormed.php
+++ b/library/HTMLPurifier/Strategy/MakeWellFormed.php
@@ -582,7 +582,9 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
         // NB not $this->zipper->insertBefore(), due to positioning
         // differences
-        return $this->zipper->splice($this->token, 0, array($token))[1];
+        $splice = $this->zipper->splice($this->token, 0, array($token));
+        return $splice[1];

Re: PHP < 5.4 Compatibility
October 22, 2013 05:18PM

Nice catch; I've applied your patch.

Re: PHP < 5.4 Compatibility
October 23, 2013 05:42AM

Thanks for your reactivity.

Your Email:


HTML input is enabled. Make sure you escape all HTML and angled brackets with &lt; and &gt;.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

Place code here

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}