ezyang / htmlpurifier

Standards compliant HTML filter written in PHP
http://htmlpurifier.org
GNU Lesser General Public License v2.1
3.07k stars 327 forks source link

PHP 8.1: fix various deprecations/errors in newest version of PHP #310

Closed davidrans closed 2 years ago

davidrans commented 2 years ago

Most of these were caught by the tests. The last commit fixed an issue the tests didn't catch that just came up using the library.

davidrans commented 2 years ago

Done!

bytestream commented 2 years ago

Closes #311

davidrans commented 2 years ago

Anything I can do to help this get merged?

davidrans commented 2 years ago

Let me know if you need anything else from me

bytestream commented 2 years ago

Just a case of waiting :p - I don't think Edward will ask for any other changes.

ezyang commented 2 years ago

What's with all the (string) casts?

davidrans commented 2 years ago

It's been a few weeks, but I think the issue was that pre-8.1 these functions did implicit string casts, and now they require a value of type string to be passed.

mhujer commented 2 years ago

See https://wiki.php.net/rfc/deprecate_null_to_scalar_internal_arg and https://3v4l.org/NAfiI

AgentSmith0 commented 2 years ago

Any updates to this?

jstanden commented 2 years ago

Thanks for the great library. 👍

There's another PHP 8.x warning at: https://github.com/ezyang/htmlpurifier/blob/master/library/HTMLPurifier/AttrTransform/TargetBlank.php#L38

Attempt to read property "browsable" on bool
pyres01 commented 2 years ago

邮件已收到,谢谢!

henriquegomes6 commented 2 years ago

any news?

marcovtwout commented 2 years ago

There's another PHP 8.x warning at: https://github.com/ezyang/htmlpurifier/blob/master/library/HTMLPurifier/AttrTransform/TargetBlank.php#L38

url->getSchemeObj() could return false, so this can be fixed with:

-    if ($scheme->browsable && !$url->isBenign($config, $context)) {
+    if ($scheme !== false && $scheme->browsable && !$url->isBenign($config, $context)) {
marcovtwout commented 2 years ago

Tested this branch through a standalone build on a few project configurations - have not seen any new errors yet. :) Looking forward to this being merged and 4.15.0 released.

AgentSmith0 commented 2 years ago

Thanks!

davidrans commented 2 years ago

Thank you!

pyres01 commented 1 year ago

邮件已收到,谢谢!