Make WordPress Core

Changeset 24510


Ignore:
Timestamp:
06/25/2013 07:03:17 PM (13 years ago)
Author:
ryan
Message:

Normalize the UTF-8 and ISO-8859-1 charset strings stored in blog_charset to make them friendlier with PHP functions that accept a charset such as htmlspecialchars().

fixes #23688

Location:
trunk/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-filters.php

    r24387 r24510  
    180180add_filter( 'option_ping_sites',        'privacy_ping_filter'                 );
    181181add_filter( 'option_blog_charset',      '_wp_specialchars'                    ); // IMPORTANT: This must not be wp_specialchars() or esc_html() or it'll cause an infinite loop
     182add_filter( 'option_blog_charset',      '_canonical_charset'                  );
    182183add_filter( 'option_home',              '_config_wp_home'                     );
    183184add_filter( 'option_siteurl',           '_config_wp_siteurl'                  );
  • trunk/wp-includes/functions.php

    r24480 r24510  
    39993999    return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) );
    40004000}
     4001
     4002/**
     4003 * Return a canonical form of the provided charset appropriate for passing to PHP
     4004 * functions such as htmlspecialchars() and charset html attributes.
     4005 *
     4006 * @link http://core.trac.wordpress.org/ticket/23688
     4007 * @since 3.6.0
     4008 *
     4009 * @param string A charset name
     4010 * @return string The canonical form of the charset
     4011 */
     4012function _canonical_charset( $charset ) {
     4013    if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset ||
     4014        'UTF8' === $charset )
     4015        return 'UTF-8';
     4016
     4017    if ( 'ISO-8859-1' === $charset || 'iso-8859-1' === $charset ||
     4018        'iso8859-1' === $charset || 'ISO8859-1' === $charset )
     4019        return 'ISO-8859-1';
     4020
     4021    return $charset;
     4022}
Note: See TracChangeset for help on using the changeset viewer.