Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ PHP NEWS
. Fixed password_get_info() and password_needs_rehash() accepting malformed
bcrypt costs. (Ilia Alshanetsky)

- Tidy:
. Fixed tidy_repair_string(), tidy_repair_file(), tidy::repairString() and
tidy::repairFile() rejecting null for $encoding. (lacatoire)

- Zip:
. Fixed use-after-free when re-entering ZipArchive during destruction or
a close warning, and rejected opening streams while closing. (jvoisin)
Expand Down
28 changes: 28 additions & 0 deletions ext/tidy/tests/tidy_repair_encoding_null.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
tidy_repair_string() / tidy_repair_file() accept null for $encoding, as declared
--EXTENSIONS--
tidy
--FILE--
<?php
declare(strict_types=1);

$file = __DIR__ . '/tidy_repair_encoding_null.html';
file_put_contents($file, '<p>test');

var_dump(strlen(tidy_repair_string('<p>test', null, null)) > 0);
var_dump(strlen(tidy_repair_file($file, null, null)) > 0);
var_dump(strlen(tidy::repairString('<p>test', null, null)) > 0);
var_dump(strlen(tidy::repairFile($file, null, null)) > 0);

var_dump(tidy_repair_string('<p>test', null, null) === tidy_repair_string('<p>test'));
?>
--CLEAN--
<?php
unlink(__DIR__ . '/tidy_repair_encoding_null.html');
?>
--EXPECT--
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)
4 changes: 2 additions & 2 deletions ext/tidy/tidy.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
Z_PARAM_PATH_STR(arg1)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(config_ht, config_str)
Z_PARAM_STRING(enc, enc_len)
Z_PARAM_STRING_OR_NULL(enc, enc_len)
Z_PARAM_BOOL(use_include_path)
ZEND_PARSE_PARAMETERS_END();

Expand All @@ -364,7 +364,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
Z_PARAM_STR(arg1)
Z_PARAM_OPTIONAL
Z_PARAM_ARRAY_HT_OR_STR_OR_NULL(config_ht, config_str)
Z_PARAM_STRING(enc, enc_len)
Z_PARAM_STRING_OR_NULL(enc, enc_len)
ZEND_PARSE_PARAMETERS_END();

data = arg1;
Expand Down
Loading