Make WordPress Core

Changeset 62484


Ignore:
Timestamp:
06/10/2026 11:37:00 PM (5 months ago)
Author:
dmsnell
Message:

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: ​https://github.com/WordPress/wordpress-develop/pull/12147
Discussed in: https://core.trac.wordpress.org/ticket/65372

Props dmsnell, jonsurrell.
Follow-up to: [60950].
See #65372.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/formatting/deprecatedUtfEncodeDecode.php

    r60950 r62484  
    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}";
Note: See TracChangeset for help on using the changeset viewer.