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. git-svn-id: https://develop.svn.wordpress.org/trunk@37469 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
898f42c2a6
commit
6d963d60c6
|
@ -3706,6 +3706,10 @@ function sanitize_option( $option, $value ) {
|
||||||
case 'blogdescription':
|
case 'blogdescription':
|
||||||
case 'blogname':
|
case 'blogname':
|
||||||
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
|
||||||
|
if ( $value !== $original_value ) {
|
||||||
|
$value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', wp_encode_emoji( $original_value ) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( is_wp_error( $value ) ) {
|
if ( is_wp_error( $value ) ) {
|
||||||
$error = $value->get_error_message();
|
$error = $value->get_error_message();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -102,4 +102,21 @@ class Tests_Sanitize_Option extends WP_UnitTestCase {
|
||||||
$this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) );
|
$this->assertSame( $expected, sanitize_option( 'upload_path', $provided ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket #36122
|
||||||
|
*/
|
||||||
|
public function test_emoji_in_blogname_and_description() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$value = "whee\xf0\x9f\x98\x88";
|
||||||
|
|
||||||
|
if ( 'utf8mb4' === $wpdb->get_col_charset( $wpdb->options, 'option_value' ) ) {
|
||||||
|
$expected = $value;
|
||||||
|
} else {
|
||||||
|
$expected = 'whee😈';
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->assertSame( $expected, sanitize_option( 'blogname', $value ) );
|
||||||
|
$this->assertSame( $expected, sanitize_option( 'blogdescription', $value ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue