Make WordPress Core


Ignore:
Timestamp:
10/03/2017 09:56:45 AM (9 years ago)
Author:
pento
Message:

Emoji: Fix incorrect emoji encoding in PHP < 5.4.

[41701] included a bug with PHP < 5.4. Prior to then, html_entity_decode() decoded into ISO-8859-1, when we actually need it to use UTF-8.

Fixes #35293.

File:
1 edited

Legend:

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

    r41701 r41702  
    123123                                // Simple emoji
    124124                                '🙂',
    125                                 '<img src="' . $this->png_cdn . '1f642.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     125                                '<img src="' . $this->png_cdn . '1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    126126                        ),
    127127                        array(
    128128                                // Skin tone, gender, ZWJ, emoji selector
    129129                                '👮🏼‍♀️',
    130                                 '<img src="' . $this->png_cdn . '1f46e-1f3fc-200d-2640-fe0f.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     130                                '<img src="' . $this->png_cdn . '1f46e-1f3fc-200d-2640-fe0f.png" alt="👮🏼‍♀️" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    131131                        ),
    132132                        array(
    133133                                // Unicode 10
    134134                                '🧚',
    135                                 '<img src="' . $this->png_cdn . '1f9da.png" alt="" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
     135                                '<img src="' . $this->png_cdn . '1f9da.png" alt="🧚" class="wp-smiley" style="height: 1em; max-height: 1em;" />',
    136136                        ),
    137137                );
    138 
    139                 // Older versions of PHP don't html_entity_decode() emoji, so we need to make sure they're testing in the expected form.
    140                 foreach ( $data as $key => $datum ) {
    141                         $emoji = html_entity_decode( wp_encode_emoji( $datum[0] ) );
    142                         $data[ $key ][1] = str_replace( 'alt=""', 'alt="' . $emoji . '"', $datum[1] );
    143                 }
    144138
    145139                return $data;
Note: See TracChangeset for help on using the changeset viewer.