Skip to content

Commit 9320753

Browse files
committed
Add test to exercise _php_mb_encoding_handler_ex with multiple possible input encodings
Thanks to Kamil Tekiela for pointing out that there was no test case for this.
1 parent d617fca commit 9320753

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
--TEST--
2+
mb_parse_str() with multiple candidate encodings
3+
--EXTENSIONS--
4+
mbstring
5+
--INI--
6+
mbstring.http_input=UTF-8,SJIS,EUC-JP
7+
--FILE--
8+
<?php
9+
// The encoding of the input strings will be guessed, from the list specified
10+
// via mbstring.http_input
11+
// All of them will be converted to UTF-8
12+
mb_internal_encoding('UTF-8');
13+
14+
$queries = array(
15+
// UTF-8
16+
"テスト=abc",
17+
// SJIS
18+
"\x82\xA0\x82\xA2\x82\xA4=\x93V"
19+
);
20+
21+
foreach ($queries as $query) {
22+
echo "Query: " . bin2hex($query) . "\n";
23+
24+
$array = [];
25+
mb_parse_str($query, $array);
26+
27+
foreach ($array as $key => $value) {
28+
echo bin2hex($key) . "=>" . bin2hex($value) . "\n";
29+
}
30+
}
31+
32+
?>
33+
--EXPECTF--
34+
Deprecated: PHP Startup: Use of mbstring.http_input is deprecated in %s on line %d
35+
Query: e38386e382b9e383883d616263
36+
e38386e382b9e38388=>616263
37+
Query: 82a082a282a43d9356
38+
e38182e38184e38186=>e5a4a9

0 commit comments

Comments
 (0)