mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Merge branch 'PHP-7.3' into PHP-7.4
* PHP-7.3: Fix #78609: mb_check_encoding() no longer supports stringable objects
This commit is contained in:
commit
70f367d48a
2
NEWS
2
NEWS
@ -15,6 +15,8 @@ PHP NEWS
|
||||
- MBString:
|
||||
. Fixed bug #78579 (mb_decode_numericentity: args number inconsistency).
|
||||
(cmb)
|
||||
. Fixed bug #78609 (mb_check_encoding() no longer supports stringable
|
||||
objects). (cmb)
|
||||
|
||||
- Standard:
|
||||
. Fixed bug #78549 (Stack overflow due to nested serialized input). (Nikita)
|
||||
|
@ -4952,27 +4952,17 @@ PHP_FUNCTION(mb_check_encoding)
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
switch(Z_TYPE_P(input)) {
|
||||
case IS_LONG:
|
||||
case IS_DOUBLE:
|
||||
case IS_NULL:
|
||||
case IS_TRUE:
|
||||
case IS_FALSE:
|
||||
RETURN_TRUE;
|
||||
break;
|
||||
case IS_STRING:
|
||||
if (!php_mb_check_encoding(Z_STRVAL_P(input), Z_STRLEN_P(input), enc ? ZSTR_VAL(enc): NULL)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
case IS_ARRAY:
|
||||
if (!php_mb_check_encoding_recursive(Z_ARRVAL_P(input), enc)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
php_error_docref(NULL, E_WARNING, "Input is something other than scalar or array");
|
||||
if (Z_TYPE_P(input) == IS_ARRAY) {
|
||||
if (!php_mb_check_encoding_recursive(HASH_OF(input), enc)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
} else {
|
||||
if (!try_convert_to_string(input)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (!php_mb_check_encoding(Z_STRVAL_P(input), Z_STRLEN_P(input), enc ? ZSTR_VAL(enc): NULL)) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
RETURN_TRUE;
|
||||
}
|
||||
|
20
ext/mbstring/tests/bug78609.phpt
Normal file
20
ext/mbstring/tests/bug78609.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
Bug #78609 (mb_check_encoding() no longer supports stringable objects)
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('mbstring')) die('skip mbstring extension not available');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
class Foo
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return 'string_representation';
|
||||
}
|
||||
}
|
||||
|
||||
var_dump(mb_check_encoding(new Foo, 'UTF-8'));
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(true)
|
Loading…
Reference in New Issue
Block a user