Welcome! » Log In » Create A New Profile

PHP < 5.4 Compatibility

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

Hello,

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.

Sorry, you do not have permission to post/reply in this forum.