[php-src] Issue #8137: DOMDocument::loadHTML everything after null character is not parsed

From: Date: Tue, 22 Feb 2022 14:43:58 +0000
Subject: [php-src] Issue #8137: DOMDocument::loadHTML everything after null character is not parsed
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-239965@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8137
Author: kenylieou

### Description

The following code:

```php
ini_set('display_errors', 1);
$d = new DOMDocument();
$html =
"<html><body><span>test1</span><span>\x0</span><span>test2</span></body></html>";
$d->loadHTML($html);
$newHtml = $d->saveHTML();

echo htmlentities($newHtml);
<?php
```

Resulted in this output:

```html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><span>test1</span><span></span></body></html>
```

But I expected this output instead:
```html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><span>test1</span><span></span><span>test2</span></body></html>
```


### PHP Version

PHP 7.4.28, PHP 8.1.0 

### Operating System

WSL Docker Ubuntu


Thread (1 message)

  • kenylieou
« previous php.bugs (#239965) next »