[php-src] PR #24288: ext/tidy: Accept null for the $encoding of the repair functions
| From: | lacatoire | Date: | Tue, 13 Oct 2026 09:19:16 +0000 |
| Subject: | [php-src] PR #24288: ext/tidy: Accept null for the $encoding of the repair functions | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-39373@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/24288
Author: lacatoire
tidy_repair_string(), tidy_repair_file(),
tidy::repairString() and tidy::repairFile() declare ?string
$encoding = null but parse it with Z_PARAM_STRING, so passing null
is rejected. All other tidy entry points already use Z_PARAM_STRING_OR_NULL for this
parameter (628db3f3b5b). null is then handled like an omitted argument:
enc_len is 0 and the encoding is not set.
Before (PHP-8.4, debug build with tidy):
```
$ php -d zend.assertions=1 -r 'declare(strict_types=1);
tidy_repair_string("<p>test", null, null);'
Fatal error: Uncaught TypeError: tidy_repair_string(): Argument #3 ($encoding) must be of type
string, null given
```
After:
```
$ sapi/cli/php run-tests.php ext/tidy
Tests passed : 51 (98.1%)
Tests failed : 0 ( 0.0%)
```
The new test tidy_repair_encoding_null.phpt fails without the fix (the
TypeError above) and passes with it.