diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 4b622a89c5..715b874a16 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -179,6 +179,7 @@ add_filter( 'the_author', 'ent2ncr', 8 ); // Misc filters add_filter( 'option_ping_sites', 'privacy_ping_filter' ); add_filter( 'option_blog_charset', '_wp_specialchars' ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop +add_filter( 'option_blog_charset', '_canonical_charset' ); add_filter( 'option_home', '_config_wp_home' ); add_filter( 'option_siteurl', '_config_wp_siteurl' ); add_filter( 'tiny_mce_before_init', '_mce_set_direction' ); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index b6739ecf78..15cd8cd47b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3998,3 +3998,25 @@ function get_tag_regex( $tag ) { return; return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) ); } + +/** + * Return a canonical form of the provided charset appropriate for passing to PHP + * functions such as htmlspecialchars() and charset html attributes. + * + * @link http://core.trac.wordpress.org/ticket/23688 + * @since 3.6.0 + * + * @param string A charset name + * @return string The canonical form of the charset + */ +function _canonical_charset( $charset ) { + if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || + 'UTF8' === $charset ) + return 'UTF-8'; + + if ( 'ISO-8859-1' === $charset || 'iso-8859-1' === $charset || + 'iso8859-1' === $charset || 'ISO8859-1' === $charset ) + return 'ISO-8859-1'; + + return $charset; +} \ No newline at end of file