[php-src] Issue #11469: PHP 8.3 regression DomNode->value setting
| From: | andypost | Date: | Sat, 17 Jun 2023 16:29:05 +0000 |
| Subject: | [php-src] Issue #11469: PHP 8.3 regression DomNode->value setting | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244728@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11469
Author: andypost
### Description
The following code:
```php
<?php
$document = <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="Content-Type" content="text/html;
charset=utf-8" /></head>
<body>
<img data-caption="This is a <a href="https://www.drupal.org">quick</a>
test…" src="llama.jpg" />
</body>
</html>
EOD;
$dom = new \DOMDocument();
$dom->loadHTML($document, LIBXML_NOBLANKS);
$xpath = new \DOMXPath($dom);
foreach ($xpath->query('//@*[starts-with(name(.), "data-")]') as $node) {
$value = $node->value;
var_dump($value);
$value = htmlspecialchars($value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
var_dump($value);
$node->value = $value;
var_dump($node->value);
}
```
Resulted in this output:
```
string(60) "This is a <a href="https://www.drupal.org">quick</a>
test…"
string(82) "This is a <a href="https://www.drupal.org">quick</a>
test…"
string(82) "This is a <a href="https://www.drupal.org">quick</a>
test…"
```
But I expected this output instead:
```
string(60) "This is a <a href="https://www.drupal.org">quick</a>
test…"
string(82) "This is a <a href="https://www.drupal.org">quick</a>
test…"
string(60) "This is a <a href="https://www.drupal.org">quick</a>
test…"
```
This is a cause of few tests failed in Drupal HEAD https://www.drupal.org/project/drupal/issues/3366843
### PHP Version
PHP 8.3.0-alpha1
### Operating System
Alpinelinux, Debian