WordPress.org

Make WordPress Core

Changeset 37469


Ignore:
Timestamp:
05/20/2016 04:53:40 AM (3 years ago)
Author:
pento
Message:

Emoji: Allow emoji in blogname and blogdescription on utf8 installs.

When the options table is set to utf8 instead of utf8mb4, emoji will be stripped from the blog name and description when they're saved. Instead of stripping them, they can be encode as HTML entities.

Fixes #36122.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r37431 r37469  
    37073707        case 'blogname':
    37083708            $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
     3709            if ( $value !== $original_value ) {
     3710                $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) );
     3711            }
     3712
    37093713            if ( is_wp_error( $value ) ) {
    37103714                $error = $value->get_error_message();
  • trunk/tests/phpunit/tests/option/sanitize-option.php

    r34519 r37469  
    103103    }
    104104
     105    /**
     106     * @ticket #36122
     107     */
     108    public function test_emoji_in_blogname_and_description() {
     109        global $wpdb;
     110
     111        $value = "whee\xf0\x9f\x98\x88";
     112
     113        if ( 'utf8mb4' === $wpdb->get_col_charset( $wpdb->options, 'option_value' ) ) {
     114            $expected = $value;
     115        } else {
     116            $expected = 'whee😈';
     117        }
     118
     119        $this->assertSame( $expected, sanitize_option( 'blogname', $value ) );
     120        $this->assertSame( $expected, sanitize_option( 'blogdescription', $value ) );
     121    }
    105122}
Note: See TracChangeset for help on using the changeset viewer.