Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Avoid a deprecated error when the attribute name is numeric and DirectLex is used #412

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

matsuo
Copy link
Contributor

@matsuo matsuo commented Jul 29, 2024

I have created a pull request for #393.
Issue #393 had shown a case where a deprecated error occurs using PHP 8.1 or later.
This PR avoids that error.

[Example]
Contents of "test-393.php"

<?php
require_once './htmlpurifier/library/HTMLPurifier.auto.php';
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$config->set('HTML.AllowedElements', ['a']);
$config->set('HTML.AllowedAttributes', ['href']);
$config->set('Core.LexerImpl', 'DirectLex');
$clean_html = $purifier->purify('<a href="https://example.com/" 10="hoge">Test</a>');
echo $clean_html . "\n";
% /opt/homebrew/opt/php@8.0/bin/php -v | head -n 1
PHP 8.0.30 (cli) (built: Jun  6 2024 19:16:32) ( NTS )
% /opt/homebrew/opt/php@8.0/bin/php test-393.php
<a href="https://example.com/">Test</a>
% /opt/homebrew/opt/php@8.1/bin/php -v | head -n 1
PHP 8.1.29 (cli) (built: Jun  5 2024 05:51:57) (NTS)
% /opt/homebrew/opt/php@8.1/bin/php test-393.php
PHP Deprecated:  ctype_lower(): Argument of type int will be interpreted as string in the future in /Users/(snip)/htmlpurifier/library/HTMLPurifier/Token/Tag.php on line 47

Deprecated: ctype_lower(): Argument of type int will be interpreted as string in the future in /Users/(snip)/htmlpurifier/library/HTMLPurifier/Token/Tag.php on line 47
<a href="https://example.com/">Test</a>

Thank you.

@pyres01
Copy link

pyres01 commented Jul 29, 2024 via email

@ezyang ezyang merged commit f0fbf51 into ezyang:master Jul 31, 2024
12 checks passed
@matsuo matsuo deleted the fix-issue-393 branch July 31, 2024 09:46
github-actions bot pushed a commit that referenced this pull request Nov 1, 2024
# [4.18.0](v4.17.0...v4.18.0) (2024-11-01)

### Bug Fixes

* Adjust Core.AllowHostnameUnderscore to consider that "_" is defined as Unreserved Characters in RFC 3986 ([#406](#406)) ([d9fbef8](d9fbef8))
* Avoid a deprecated error when the attribute name is numeric and DirectLex is used ([#412](#412)) ([f0fbf51](f0fbf51))
* checking that node has property name ([#399](#399)) ([9ca5a36](9ca5a36))
* Ignore conditional comments ([#401](#401)) ([4828fdf](4828fdf))
* Support PHP 8.4 ([#396](#396)) ([92da247](92da247))
* undefined array key warning ([#419](#419)) ([01be377](01be377))

### Features

* Add allowfullscreen attr for iframe ([#411](#411)) ([70754a2](70754a2))
* add directive for removing blank nodes ([#404](#404)) ([c9d60c9](c9d60c9))
* Add support for CSS aspect-ratio ([#408](#408)) ([93bee73](93bee73))
* Allow universal CSS values for all properties ([#410](#410)) ([9723267](9723267))
Copy link

github-actions bot commented Nov 1, 2024

🎉 This PR is included in version 4.18.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants