Welcome! » Log In » Create A New Profile

Html Purfier & Php 7

Posted by Php7 
Html Purfier & Php 7
December 09, 2015 04:36PM

Do you plan to update Html Purifier for Php 7? For example, you use a lot the function list(), that is changed. Thanks,

Re: Html Purfier & Php 7
December 20, 2015 02:58PM

It's a good idea, but many of the libraries we use for testing don't currently work on PHP 7, which makes it difficult to properly do porting work. I will happily accept patches that fix PHP 7 problems which are BC with PHP 5.

TimWolla
Re: Html Purfier & Php 7
January 04, 2016 09:04AM

Hi

where exactly lie the issues with the third party libraries? Using Simpletest 1.1.0 from the official homepage, Net/IDNA2 0.1.1 from Pear, CSSTidy 1.3 from Source Forge and PHPT master from GitHub I get the following results:

PHP 5.6.15

root@171cff907cac:/pwd/tests# php index.php 
All HTML Purifier tests on PHP 5.6.15
1) Identical expectation [String: #foo p {
text-indent:1em;
}] fails with [String: ] at character 0 with [#foo p {
text-indent:1em;
}] and [] at [/pwd/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php line 154]
	in test_cleanCSS_scopeWithNaughtySelector
	in HTMLPurifier_Filter_ExtractStyleBlocksTest
2) Identical expectation [String: #foo p {
text-indent:1em;
}] fails with [String: ] at character 0 with [#foo p {
text-indent:1em;
}] and [] at [/pwd/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php line 160]
	in test_cleanCSS_scopeWithMultipleNaughtySelectors
	in HTMLPurifier_Filter_ExtractStyleBlocksTest
Skip: domxml not loaded [HTMLPurifier/PHPT/domxml.phpt]
Skip: spl_autoload_register() available [HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt]
Skip: spl_autoload_register() available [HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt]
Skip: non-buggy version of PHP [HTMLPurifier/PHPT/loading/error-auto-with-spl-nonstatic-autoload.phpt]
3) 001- <b>Salsa!</b>
002+ Warning: require(../library/HTMLPurifier.standalone.php): failed to open stream: No such file or directory in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-autoload.php on line 2
004+ Fatal error: require(): Failed opening required &#039;../library/HTMLPurifier.standalone.php&#039; (include_path=&#039;.:/usr/local/lib/php&#039;) in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-autoload.php on line 2
	in testPhpt
	in HTMLPurifier/PHPT/loading/standalone-autoload.phpt
4) 001- <b>Salsa!</b>
002+ Warning: require(HTMLPurifier.standalone.php): failed to open stream: No such file or directory in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.php on line 4
004+ Fatal error: require(): Failed opening required &#039;HTMLPurifier.standalone.php&#039; (include_path=&#039;/pwd/library:.:/usr/local/lib/php&#039;) in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.php on line 4
	in testPhpt
	in HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt
5) 001- <b>Salsa!</b>
002+ Warning: require(../library/HTMLPurifier.standalone.php): failed to open stream: No such file or directory in /pwd/tests/HTMLPurifier/PHPT/loading/standalone.php on line 2
004+ Fatal error: require(): Failed opening required &#039;../library/HTMLPurifier.standalone.php&#039; (include_path=&#039;.:/usr/local/lib/php&#039;) in /pwd/tests/HTMLPurifier/PHPT/loading/standalone.php on line 2
	in testPhpt
	in HTMLPurifier/PHPT/loading/standalone.phpt
Skip: ze1_compatibility_mode not present in PHP 5.3 or later [HTMLPurifier/PHPT/ze1_compatibility_mode.phpt]
FAILURES!!!
Test cases run: 237/237, Passes: 2699, Failures: 5, Exceptions: 0

PHP 7.0.1

root@b944e9903fe8:/pwd/tests# php index.php 

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; TestSuite has a deprecated constructor in /pwd/simpletest/test_case.php on line 477

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; BadTestSuite has a deprecated constructor in /pwd/simpletest/test_case.php on line 612

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingXmlTag has a deprecated constructor in /pwd/simpletest/xml.php on line 292

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingMethodTag has a deprecated constructor in /pwd/simpletest/xml.php on line 342

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingCaseTag has a deprecated constructor in /pwd/simpletest/xml.php on line 382

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingGroupTag has a deprecated constructor in /pwd/simpletest/xml.php on line 422

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleTestXmlParser has a deprecated constructor in /pwd/simpletest/xml.php on line 474

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleMock has a deprecated constructor in /pwd/simpletest/mock_objects.php on line 639

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleRealm has a deprecated constructor in /pwd/simpletest/authentication.php on line 18

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleAuthenticator has a deprecated constructor in /pwd/simpletest/authentication.php on line 131

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; csstidy has a deprecated constructor in /pwd/csstidy/class.csstidy.php on line 61

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; csstidy_print has a deprecated constructor in /pwd/csstidy/class.csstidy_print.php on line 39

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; csstidy_optimise has a deprecated constructor in /pwd/csstidy/class.csstidy_optimise.php on line 39

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; HTMLPurifier_AttrDef_CSS_Composite_Testable has a deprecated constructor in /pwd/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php on line 3
All HTML Purifier tests on PHP 7.0.1
Exception 1!
Unexpected PHP error [Uninitialized string offset: -1] severity [8] in [/pwd/library/HTMLPurifier/AttrDef/CSS/URI.php line 37]
	in test
	in HTMLPurifier_AttrDef_CSS_URITest
1) Identical expectation [String: #foo p {
text-indent:1em;
}] fails with [String: ] at character 0 with [#foo p {
text-indent:1em;
}] and [] at [/pwd/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php line 154]
	in test_cleanCSS_scopeWithNaughtySelector
	in HTMLPurifier_Filter_ExtractStyleBlocksTest
2) Identical expectation [String: #foo p {
text-indent:1em;
}] fails with [String: ] at character 0 with [#foo p {
text-indent:1em;
}] and [] at [/pwd/tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php line 160]
	in test_cleanCSS_scopeWithMultipleNaughtySelectors
	in HTMLPurifier_Filter_ExtractStyleBlocksTest
Skip: domxml not loaded [HTMLPurifier/PHPT/domxml.phpt]
Skip: spl_autoload_register() available [HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt]
Skip: spl_autoload_register() available [HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt]
Skip: non-buggy version of PHP [HTMLPurifier/PHPT/loading/error-auto-with-spl-nonstatic-autoload.phpt]
3) 001- <b>Salsa!</b>
002+ Warning: require(../library/HTMLPurifier.standalone.php): failed to open stream: No such file or directory in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-autoload.php on line 2
004+ Fatal error: require(): Failed opening required &#039;../library/HTMLPurifier.standalone.php&#039; (include_path=&#039;.:/usr/local/lib/php&#039;) in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-autoload.php on line 2
	in testPhpt
	in HTMLPurifier/PHPT/loading/standalone-autoload.phpt
4) 001- <b>Salsa!</b>
002+ Warning: require(HTMLPurifier.standalone.php): failed to open stream: No such file or directory in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.php on line 4
004+ Fatal error: require(): Failed opening required &#039;HTMLPurifier.standalone.php&#039; (include_path=&#039;/pwd/library:.:/usr/local/lib/php&#039;) in /pwd/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.php on line 4
	in testPhpt
	in HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt
5) 001- <b>Salsa!</b>
002+ Warning: require(../library/HTMLPurifier.standalone.php): failed to open stream: No such file or directory in /pwd/tests/HTMLPurifier/PHPT/loading/standalone.php on line 2
004+ Fatal error: require(): Failed opening required &#039;../library/HTMLPurifier.standalone.php&#039; (include_path=&#039;.:/usr/local/lib/php&#039;) in /pwd/tests/HTMLPurifier/PHPT/loading/standalone.php on line 2
	in testPhpt
	in HTMLPurifier/PHPT/loading/standalone.phpt
Skip: ze1_compatibility_mode not present in PHP 5.3 or later [HTMLPurifier/PHPT/ze1_compatibility_mode.phpt]
FAILURES!!!
Test cases run: 237/237, Passes: 2699, Failures: 5, Exceptions: 1

Doesn't look too bad to me? Apart from a few warnings the only difference seems to be that PHP 7 throws an Exception where PHP 5.6 did not:

Exception 1!
Unexpected PHP error [Uninitialized string offset: -1] severity [8] in [/pwd/library/HTMLPurifier/AttrDef/CSS/URI.php line 37]
	in test
	in HTMLPurifier_AttrDef_CSS_URITest

Best regards

Re: Html Purfier & Php 7
January 04, 2016 06:22PM

Hmm... when I run PHPT I get:

ezyang@sabre:~/Dev/htmlpurifier$ php7.0 tests/index.php 

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; TestSuite has a deprecated constructor in /srv/code/simpletest/test_case.php on line 477

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; BadTestSuite has a deprecated constructor in /srv/code/simpletest/test_case.php on line 612

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingXmlTag has a deprecated constructor in /srv/code/simpletest/xml.php on line 292

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingMethodTag has a deprecated constructor in /srv/code/simpletest/xml.php on line 342

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingCaseTag has a deprecated constructor in /srv/code/simpletest/xml.php on line 382

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; NestingGroupTag has a deprecated constructor in /srv/code/simpletest/xml.php on line 422

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleTestXmlParser has a deprecated constructor in /srv/code/simpletest/xml.php on line 474

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleMock has a deprecated constructor in /srv/code/simpletest/mock_objects.php on line 639

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleRealm has a deprecated constructor in /srv/code/simpletest/authentication.php on line 18

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; SimpleAuthenticator has a deprecated constructor in /srv/code/simpletest/authentication.php on line 131

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; csstidy has a deprecated constructor in /srv/code/csstidy/class.csstidy.php on line 64

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; csstidy_print has a deprecated constructor in /srv/code/csstidy/class.csstidy_print.php on line 41

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; csstidy_optimise has a deprecated constructor in /srv/code/csstidy/class.csstidy_optimise.php on line 41

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; HTMLPurifier_AttrDef_CSS_Composite_Testable has a deprecated constructor in /srv/www/htmlpurifier/tests/HTMLPurifier/AttrDef/CSS/CompositeTest.php on line 3
All HTML Purifier tests on PHP 7.0.1-2+deb.sury.org~vivid+1
Exception 1!
Unexpected PHP error [Uninitialized string offset: -1] severity [8] in [/srv/www/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php line 37]
	in test
	in HTMLPurifier_AttrDef_CSS_URITest
Skip: domxml not loaded [HTMLPurifier/PHPT/domxml.phpt]
Skip: spl_autoload_register() available [HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt]
Skip: spl_autoload_register() available [HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt]
Skip: non-buggy version of PHP [HTMLPurifier/PHPT/loading/error-auto-with-spl-nonstatic-autoload.phpt]

Parse error: syntax error, unexpected &#039;=&#039; in /srv/code/PHPT_Core/src/PHPT/Util/Code.php(47) : eval()&#039;d code on line 1

I hadn't investigated further. Well, sounds like HTML Purifier may mostly work in any case! Hopefully some of the bugs will be fixable in a BC way.

TimWolla
Re: Html Purfier & Php 7
January 04, 2016 07:53PM
Hmm... when I run PHPT I get:

It might be that you installed a few more test dependencies than me, leading to running a test that causes this behaviour. But fixing this for you is not hard: In /srv/code/PHPT_Core/src/PHPT/Util/Code.php on line 47 you will find:

$this->_valid = @(eval($code) !== false);

change this to:

try {
  $this->_valid = @(eval($code) !== false);
}
catch (\ParseError $e) {
  $this->_valid = false;
}

and the test should execute normally. In PHP < 7 eval returned false for a syntax error, as of PHP 7 it throws.

Re: Html Purfier & Php 7
March 23, 2016 02:54PM

I hope that PHP 7 can be "officially" supported soon. We use HTML Purifier in our platform and are wary to tell users it works on PHP 7 until HTML Purifier does too as it's an important part.

Re: Html Purfier & Php 7
March 24, 2016 03:21AM

I've just pushed official support for PHP 7 to the repository.

commit 7e49ff3dcdd3af0b159e7229a362bac52cd8f0ea
Author: Edward Z. Yang 
Date:   Thu Mar 24 00:14:05 2016 -0700

    Announce PHP 7 support.
    
    Signed-off-by: Edward Z. Yang 

To get the test suite running with no errors you do need to fix the code generation in SimpleTest for mocking, but that is all, I believe.

Michael Jansen
Re: Html Purfier & Php 7
June 20, 2016 04:24AM

Do you have a roadmap for PHP 7 support? When do you plan a PHP 7 compliant release (e.g. v. 4.8.0)?

Jonaste
Re: Html Purfier & Php 7
June 27, 2016 12:50AM

Any update? this has been delayed for quite some time now.

Re: Html Purfier & Php 7
October 28, 2016 05:08AM

PHP 7.0 support was officially added in 4.8.0 which was released 2016-07-16

Author:
Your Email:

Subject:

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:

<pre><![CDATA[
Place code here
]]></pre>

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}

Message: