mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
ext/mbstring: Always throw ValueErrors for invalid mb_http_input() type
This commit is contained in:
parent
5f3b4c5d6c
commit
88ba9dc61b
@ -34,6 +34,7 @@ PHP 8.4 UPGRADE NOTES
|
||||
- MBString:
|
||||
. mb_encode_numericentity() and mb_decode_numericentity() now check that
|
||||
the $map is only composed of integers, if not a ValueError is thrown.
|
||||
. mb_http_input() now always throws a ValueError if the $type is invalid.
|
||||
|
||||
- PDO_DBLIB:
|
||||
. setAttribute, DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER and DBLIB_ATTR_DATETIME_CONVERT
|
||||
|
@ -1271,6 +1271,10 @@ PHP_FUNCTION(mb_http_input)
|
||||
|
||||
if (type == NULL) {
|
||||
encoding = MBSTRG(http_input_identify);
|
||||
} else if (type_len != 1) {
|
||||
zend_argument_value_error(1,
|
||||
"must be one of \"G\", \"P\", \"C\", \"S\", \"I\", or \"L\"");
|
||||
RETURN_THROWS();
|
||||
} else {
|
||||
switch (*type) {
|
||||
case 'G':
|
||||
|
@ -22,11 +22,6 @@ var_dump(mb_http_input('C'));
|
||||
var_dump(mb_http_input('S'));
|
||||
var_dump(mb_http_input('I'));
|
||||
var_dump(mb_http_input('L'));
|
||||
try {
|
||||
var_dump(mb_http_input('Q'));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
@ -41,4 +36,3 @@ array(1) {
|
||||
string(10) "ISO-8859-1"
|
||||
}
|
||||
string(10) "ISO-8859-1"
|
||||
mb_http_input(): Argument #1 ($type) must be one of "G", "P", "C", "S", "I", or "L"
|
||||
|
22
ext/mbstring/tests/mb_http_input_errors.phpt
Normal file
22
ext/mbstring/tests/mb_http_input_errors.phpt
Normal file
@ -0,0 +1,22 @@
|
||||
--TEST--
|
||||
mb_http_input() errors:
|
||||
--EXTENSIONS--
|
||||
mbstring
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
try {
|
||||
var_dump(mb_http_input('PN'));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
try {
|
||||
var_dump(mb_http_input('Q'));
|
||||
} catch (ValueError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
mb_http_input(): Argument #1 ($type) must be one of "G", "P", "C", "S", "I", or "L"
|
||||
mb_http_input(): Argument #1 ($type) must be one of "G", "P", "C", "S", "I", or "L"
|
Loading…
Reference in New Issue
Block a user