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/[email protected]/bin/php -v | head -n 1
PHP 8.0.30 (cli) (built: Jun  6 2024 19:16:32) ( NTS )
% /opt/homebrew/opt/[email protected]/bin/php test-393.php
<a href="https://example.com/">Test</a>
% /opt/homebrew/opt/[email protected]/bin/php -v | head -n 1
PHP 8.1.29 (cli) (built: Jun  5 2024 05:51:57) (NTS)
% /opt/homebrew/opt/[email protected]/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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants