Skip to content

Commit 623bf96

Browse files
committed
Throw on invalid mb_http_input() type
1 parent ace876c commit 623bf96

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

ext/mbstring/mbstring.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,9 +1377,9 @@ PHP_FUNCTION(mb_http_input)
13771377
mbfl_string_clear(&result);
13781378
return;
13791379
default:
1380-
// TODO ValueError
1381-
encoding = MBSTRG(http_input_identify);
1382-
break;
1380+
zend_argument_value_error(1,
1381+
"must be one of \"G\", \"P\", \"C\", \"S\", \"I\" or \"L\"");
1382+
RETURN_THROWS();
13831383
}
13841384
}
13851385

ext/mbstring/tests/mb_http_input.phpt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,27 @@ echo $_GET['b']."\n";
2020
// Get encoding
2121
var_dump(mb_http_input('P'));
2222
var_dump(mb_http_input('G'));
23+
var_dump(mb_http_input('C'));
24+
var_dump(mb_http_input('S'));
25+
var_dump(mb_http_input('I'));
26+
var_dump(mb_http_input('L'));
27+
try {
28+
var_dump(mb_http_input('Q'));
29+
} catch (ValueError $e) {
30+
echo $e->getMessage(), "\n";
31+
}
2332

2433
?>
2534
--EXPECT--
2635
ÆüËܸì0123456789ÆüËܸ쥫¥¿¥«¥Ê¤Ò¤é¤¬¤Ê
2736
ÆüËܸì0123456789ÆüËܸ쥫¥¿¥«¥Ê¤Ò¤é¤¬¤Ê
2837
string(10) "ISO-8859-1"
2938
string(10) "ISO-8859-1"
39+
bool(false)
40+
bool(false)
41+
array(1) {
42+
[0]=>
43+
string(10) "ISO-8859-1"
44+
}
45+
string(10) "ISO-8859-1"
46+
mb_http_input(): Argument #1 ($type) must be one of "G", "P", "C", "S", "I" or "L"

0 commit comments

Comments
 (0)