Skip to content

Commit 1db6694

Browse files
author
Rui Hirokawa
committed
added test code for #65045.
1 parent c6a7549 commit 1db6694

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

ext/mbstring/tests/bug65045.phpt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--TEST--
2+
Bug #65045: mb_convert_encoding breaks well-formed character
3+
--SKIPIF--
4+
<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
5+
--FILE--
6+
<?php
7+
8+
//declare(encoding = 'UTF-8');
9+
mb_internal_encoding('UTF-8');
10+
11+
$str = "\xF0\xA4\xAD". "\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2";
12+
$expected = "\xEF\xBF\xBD"."\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2";
13+
14+
$str2 = "\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD";
15+
$expected2 = "\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2"."\xEF\xBF\xBD";
16+
17+
mb_substitute_character(0xFFFD);
18+
var_dump(
19+
$expected === htmlspecialchars_decode(htmlspecialchars($str, ENT_SUBSTITUTE, 'UTF-8')),
20+
$expected2 === htmlspecialchars_decode(htmlspecialchars($str2, ENT_SUBSTITUTE, 'UTF-8')),
21+
$expected === mb_convert_encoding($str, 'UTF-8', 'UTF-8'),
22+
$expected2 === mb_convert_encoding($str2, 'UTF-8', 'UTF-8')
23+
);
24+
25+
--EXPECT--
26+
bool(true)
27+
bool(true)
28+
bool(true)
29+
bool(true)

0 commit comments

Comments
 (0)