Skip to content

Commit 6c363d4

Browse files
committed
Charset: Fix broken test for utf8_decode() fallback.
Detected while fuzz-testing the UTF-8 handling code, this defect meant that the tests were verifying the wrong behavior. Namely, they verified a stringification of ASCII digits, which always converted plainly, when they were meant to test handling of invalid UTF-8 sequences. This patch fixes the test by calling `chr()` on the byte values before concatenating into a big string. Developed in: WordPress#12147 Discussed in: https://core.trac.wordpress.org/ticket/65372 Props dmsnell, jonsurrell. Follow-up to: [60950]. See #65372. git-svn-id: https://develop.svn.wordpress.org/trunk@62484 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 84c04cd commit 6c363d4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

tests/phpunit/tests/formatting/deprecatedUtfEncodeDecode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function test_utf8_decode_characters() {
6868
* Since the UTF-16 surrogate halves are not valid Unicode characters,
6969
* these have to be manually constructed as invalid UTF-8.
7070
*/
71-
$byte1 = 0xE0 | ( $i >> 12 );
72-
$byte2 = 0x80 | ( ( $i >> 6 ) & 0x3F );
73-
$byte3 = 0x80 | ( $i & 0x3F );
71+
$byte1 = chr( 0xE0 | ( $i >> 12 ) );
72+
$byte2 = chr( 0x80 | ( ( $i >> 6 ) & 0x3F ) );
73+
$byte3 = chr( 0x80 | ( $i & 0x3F ) );
7474

7575
$c = "{$byte1}{$byte2}{$byte3}";
7676
}

0 commit comments

Comments
 (0)