diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index bac3ad787d..c708a26e98 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -5290,9 +5290,7 @@ function wp_emoji_regex( $type = 'codepoints' ) { // If we're using a PCRE version that doesn't support Unicode, return a loose match regex. if ( 'codepoints' === $type && ( ! defined( 'PCRE_VERSION' ) || version_compare( PCRE_VERSION, '8.32', '<=' ) ) ) { return '/( - \xE2\x98[\x80-\xFF] # Symbols - | \xE2\x99[\x00-\xFF] - | [\xE3-\xED][\x00-\xFF]{2} + \xE2\x99[\x80-\x82] # Male and female symbols | [\x23\x30-\x39]\xE2\x83\xA3 # Digits | \xF0\x9F[\x85-\x88][\xA6-\xBF] # Enclosed characters | \xF0\x9F[\x8C-\x97][\x80-\xBF] # Misc diff --git a/tests/phpunit/tests/formatting/Emoji.php b/tests/phpunit/tests/formatting/Emoji.php index cc98b4290d..856f02a711 100644 --- a/tests/phpunit/tests/formatting/Emoji.php +++ b/tests/phpunit/tests/formatting/Emoji.php @@ -101,7 +101,6 @@ class Tests_Formatting_Emoji extends WP_UnitTestCase { '🧚', '🧚', ), - ); } @@ -114,7 +113,7 @@ class Tests_Formatting_Emoji extends WP_UnitTestCase { } public function data_wp_staticize_emoji() { - return array( + $data = array( array( // Not emoji '’', @@ -123,20 +122,27 @@ class Tests_Formatting_Emoji extends WP_UnitTestCase { array( // Simple emoji '🙂', - '🙂', + '', ), array( // Skin tone, gender, ZWJ, emoji selector '👮🏼‍♀️', - '👮🏼‍♀️', + '', ), array( // Unicode 10 '🧚', - '🧚', + '', ), - ); + + // Older versions of PHP don't html_entity_decode() emoji, so we need to make sure they're testing in the expected form. + foreach ( $data as $key => $datum ) { + $emoji = html_entity_decode( wp_encode_emoji( $datum[0] ) ); + $data[ $key ][1] = str_replace( 'alt=""', 'alt="' . $emoji . '"', $datum[1] ); + } + + return $data; } /**