Skip to content

DOMAttr unescapes character reference #8388

@t-tera

Description

@t-tera

Description

The following code:

<?php
$node = new DOMAttr('foo','bar');
$node->nodeValue = 'xx&#x31;yy';
var_dump($node->nodeValue);

Resulted in this output:

xx1yy

But I expected this output instead:

xx&#x31;yy

As shown above, setter of nodeValue unescapes character references.
Because of this, I need to do the following:

$node->nodeValue = htmlspecialchars("xx&#x31;yy");
var_dump($node->nodeValue);

This outputs xx&#x31;yy. The setter should not unescape character references.

PHP Version

PHP 7.4.3

Operating System

Ubuntu 20.04

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions