8000 fix: Avoid a deprecated error when the attribute name is numeric and DirectLex is used by matsuo · Pull Request #412 · ezyang/htmlpurifier · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

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

Merged
merged 2 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/HTMLPurifier/Token/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct($name, $attr = array(), $line = null, $col = null, $
$this->name = ctype_lower($name) ? $name : strtolower($name);
foreach ($attr as $key => $value) {
// normalization only necessary when key is not lowercase
if (!ctype_lower($key)) {
if (!ctype_lower((string)$key)) {
$new_key = strtolower($key);
if (!isset($attr[$new_key])) {
$attr[$new_key] = $attr[$key];
Expand Down
11 changes: 11 additions & 0 deletions tests/HTMLPurifier/HTMLDefinitionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,17 @@ public function test_AllowedAttributes_multipleErrors()
$this->assertPurification_AllowedAttributes_local_p_style();
}

public function test_AllowedAttributes_invalidAttributeDueToConsistingOfNumbers_UsingDirectLex()
{
$this->config->set('HTML.AllowedElements', array('a'));
$this->config->set('HTML.AllowedAttributes', 'href');
$this->config->set('Core.LexerImpl', 'DirectLex');
$this->assertPurification(
'<a href="https://example.com/" 10="hoge">Test</a>',
'<a href="https://example.com/">Test</a>'
);
}

public function test_ForbiddenElements()
{
$this->config->set('HTML.ForbiddenElements', 'b');
Expand Down
Loading
0