File tree Expand file tree Collapse file tree 3 files changed +32
-20
lines changed Expand file tree Collapse file tree 3 files changed +32
-20
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ PHP NEWS
15
15
- MBString:
16
16
. Fixed bug #78579 (mb_decode_numericentity: args number inconsistency).
17
17
(cmb)
18
+ . Fixed bug #78609 (mb_check_encoding() no longer supports stringable
19
+ objects). (cmb)
18
20
19
21
- Standard:
20
22
. Fixed bug #78549 (Stack overflow due to nested serialized input). (Nikita)
Original file line number Diff line number Diff line change @@ -4952,27 +4952,17 @@ PHP_FUNCTION(mb_check_encoding)
4952
4952
RETURN_FALSE ;
4953
4953
}
4954
4954
4955
- switch (Z_TYPE_P (input )) {
4956
- case IS_LONG :
4957
- case IS_DOUBLE :
4958
- case IS_NULL :
4959
- case IS_TRUE :
4960
- case IS_FALSE :
4961
- RETURN_TRUE ;
4962
- break ;
4963
- case IS_STRING :
4964
- if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
4965
- RETURN_FALSE ;
4966
- }
4967
- break ;
4968
- case IS_ARRAY :
4969
- if (!php_mb_check_encoding_recursive (Z_ARRVAL_P (input ), enc )) {
4970
- RETURN_FALSE ;
4971
- }
4972
- break ;
4973
- default :
4974
- php_error_docref (NULL , E_WARNING , "Input is something other than scalar or array" );
4955
+ if (Z_TYPE_P (input ) == IS_ARRAY ) {
4956
+ if (!php_mb_check_encoding_recursive (HASH_OF (input ), enc )) {
4957
+ RETURN_FALSE ;
4958
+ }
4959
+ } else {
4960
+ if (!try_convert_to_string (input )) {
4961
+ RETURN_FALSE ;
4962
+ }
4963
+ if (!php_mb_check_encoding (Z_STRVAL_P (input ), Z_STRLEN_P (input ), enc ? ZSTR_VAL (enc ): NULL )) {
4975
4964
RETURN_FALSE ;
4965
+ }
4976
4966
}
4977
4967
RETURN_TRUE ;
4978
4968
}
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #78609 (mb_check_encoding() no longer supports stringable objects)
3
+ --SKIPIF--
4
+ <?php
5
+ if (!extension_loaded ('mbstring ' )) die ('skip mbstring extension not available ' );
6
+ ?>
7
+ --FILE--
8
+ <?php
9
+ class Foo
10
+ {
11
+ public function __toString ()
12
+ {
13
+ return 'string_representation ' ;
14
+ }
15
+ }
16
+
17
+ var_dump (mb_check_encoding (new Foo , 'UTF-8 ' ));
18
+ ?>
19
+ --EXPECT--
20
+ bool(true)
You can’t perform that action at this time.
0 commit comments