mirror of
git://develop.git.wordpress.org/
synced 2025-03-15 01:19:51 +01:00
Emoji: Fix some failing unit tests in PHP 5.2 and 5.3.
- Older versions of PHP don't know how to `html_entity_decode()` emoji. - The fall back regex was a little too broad, catching characters that aren't emoji. See #35293. git-svn-id: https://develop.svn.wordpress.org/trunk@41045 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f780ce0a49
commit
4bad064c24
@ -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
|
||||
|
@ -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
|
||||
'🙂',
|
||||
'<img src="' . $this->png_cdn . '1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
|
||||
'<img src="' . $this->png_cdn . '1f642.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
|
||||
),
|
||||
array(
|
||||
// Skin tone, gender, ZWJ, emoji selector
|
||||
'👮🏼♀️',
|
||||
'<img src="' . $this->png_cdn . '1f46e-1f3fc-200d-2640-fe0f.png" alt="👮🏼♀️" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
|
||||
'<img src="' . $this->png_cdn . '1f46e-1f3fc-200d-2640-fe0f.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
|
||||
),
|
||||
array(
|
||||
// Unicode 10
|
||||
'🧚',
|
||||
'<img src="' . $this->png_cdn . '1f9da.png" alt="🧚" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
|
||||
'<img src="' . $this->png_cdn . '1f9da.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
|
||||
),
|
||||
|
||||
);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user