Skip to content

Commit 604cbf9

Browse files
committed
Merge branch 'PHP-8.5' into PHP-8.6
* PHP-8.5: ext/tidy: Accept null for the $encoding of the repair functions
2 parents e3ff9f1 + 58a3ab5 commit 604cbf9

3 files changed

Lines changed: 34 additions & 2 deletions

File tree

‎NEWS‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ PHP NEWS
7373
. Fixed password_get_info() and password_needs_rehash() accepting malformed
7474
bcrypt costs. (Ilia Alshanetsky)
7575

76+
- Tidy:
77+
. Fixed tidy_repair_string(), tidy_repair_file(), tidy::repairString() and
78+
tidy::repairFile() rejecting null for $encoding. (lacatoire)
79+
7680
- Zip:
7781
. Fixed use-after-free when re-entering ZipArchive during destruction or
7882
a close warning, and rejected opening streams while closing. (jvoisin)
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--TEST--
2+
tidy_repair_string() / tidy_repair_file() accept null for $encoding, as declared
3+
--EXTENSIONS--
4+
tidy
5+
--FILE--
6+
<?php
7+
declare(strict_types=1);
8+
9+
$file = __DIR__ . '/tidy_repair_encoding_null.html';
10+
file_put_contents($file, '<p>test');
11+
12+
var_dump(strlen(tidy_repair_string('<p>test', null, null)) > 0);
13+
var_dump(strlen(tidy_repair_file($file, null, null)) > 0);
14+
var_dump(strlen(tidy::repairString('<p>test', null, null)) > 0);
15+
var_dump(strlen(tidy::repairFile($file, null, null)) > 0);
16+
17+
var_dump(tidy_repair_string('<p>test', null, null) === tidy_repair_string('<p>test'));
18+
?>
19+
--CLEAN--
20+
<?php
21+
unlink(__DIR__ . '/tidy_repair_encoding_null.html');
22+
?>
23+
--EXPECT--
24+
bool(true)
25+
bool(true)
26+
bool(true)
27+
bool(true)
28+
bool(true)

‎ext/tidy/tidy.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
261261
Z_PARAM_PATH_STR(arg1)
262262
Z_PARAM_OPTIONAL
263263
Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(config_ht, config_str)
264-
Z_PARAM_STRING(enc, enc_len)
264+
Z_PARAM_STRING_OR_NULL(enc, enc_len)
265265
Z_PARAM_BOOL(use_include_path)
266266
ZEND_PARSE_PARAMETERS_END();
267267

@@ -273,7 +273,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
273273
Z_PARAM_STR(arg1)
274274
Z_PARAM_OPTIONAL
275275
Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(config_ht, config_str)
276-
Z_PARAM_STRING(enc, enc_len)
276+
Z_PARAM_STRING_OR_NULL(enc, enc_len)
277277
ZEND_PARSE_PARAMETERS_END();
278278

279279
data = arg1;

0 commit comments

Comments
 (0)