diff --git a/NEWS b/NEWS index cd3a34557f9..c47a2db8b55 100644 --- a/NEWS +++ b/NEWS @@ -73,6 +73,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) diff --git a/ext/tidy/tests/tidy_repair_encoding_null.phpt b/ext/tidy/tests/tidy_repair_encoding_null.phpt new file mode 100644 index 00000000000..e1948724df5 --- /dev/null +++ b/ext/tidy/tests/tidy_repair_encoding_null.phpt @@ -0,0 +1,28 @@ +--TEST-- +tidy_repair_string() / tidy_repair_file() accept null for $encoding, as declared +--EXTENSIONS-- +tidy +--FILE-- +test'); + +var_dump(strlen(tidy_repair_string('
test', null, null)) > 0); +var_dump(strlen(tidy_repair_file($file, null, null)) > 0); +var_dump(strlen(tidy::repairString('
test', null, null)) > 0); +var_dump(strlen(tidy::repairFile($file, null, null)) > 0); + +var_dump(tidy_repair_string('
test', null, null) === tidy_repair_string('
test')); +?> +--CLEAN-- + +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index dcb87dd509b..a47871ede0d 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -261,7 +261,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(); @@ -273,7 +273,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;