mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fix assertion failure when failing to detect encoding
Looks like prior to 7.3 this just passed the original string through. Since 7.3 it returns false. Let's stick with that behavior.
This commit is contained in:
parent
9d869f24d4
commit
71f48260af
@ -2489,9 +2489,6 @@ MBSTRING_API char *php_mb_convert_encoding(const char *input, size_t length, con
|
||||
if (output_len) {
|
||||
*output_len = 0;
|
||||
}
|
||||
if (!input) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* pre-conversion encoding */
|
||||
ZEND_ASSERT(num_from_encodings >= 1);
|
||||
@ -2507,7 +2504,7 @@ MBSTRING_API char *php_mb_convert_encoding(const char *input, size_t length, con
|
||||
&string, from_encodings, num_from_encodings, MBSTRG(strict_detection));
|
||||
if (!from_encoding) {
|
||||
php_error_docref(NULL, E_WARNING, "Unable to detect character encoding");
|
||||
from_encoding = &mbfl_encoding_pass;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
11
ext/mbstring/tests/mb_convert_encoding_failed_detection.phpt
Normal file
11
ext/mbstring/tests/mb_convert_encoding_failed_detection.phpt
Normal file
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
mb_convert_encoding() when encoding detection fails
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
var_dump(mb_convert_encoding("\xff", "ASCII", ["UTF-8", "UTF-16"]));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
|
||||
bool(false)
|
Loading…
Reference in New Issue
Block a user