Charset: Allow `_canonical_charset()` to handle mixed-case strings.

Add improved unit tests, and collect existing unit tests together.

Props pbearne.
Fixes #38337.


Built from https://develop.svn.wordpress.org/trunk@38809


git-svn-id: http://core.svn.wordpress.org/trunk@38752 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2016-10-17 23:54:30 +00:00
parent f76fa00288
commit f6d85de626
2 changed files with 9 additions and 7 deletions

View File

@ -555,7 +555,7 @@ function do_enclose( $content, $post_ID ) {
global $wpdb;
//TODO: Tidy this ghetto code up and make the debug code optional
include_once( ABSPATH . WPINC . '/class-IXR.php' );
include_once( ABSPATH . WPINC . '/class-IXR.php' );
$post_links = array();
@ -5250,13 +5250,15 @@ function get_tag_regex( $tag ) {
* @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 ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset) ) {
return 'UTF-8';
}
if ( 'iso-8859-1' === strtolower( $charset ) || 'iso8859-1' === strtolower( $charset ) ) {
if ( 'ISO-8859-1' === $charset || 'iso-8859-1' === $charset ||
'iso8859-1' === $charset || 'ISO8859-1' === $charset )
return 'ISO-8859-1';
}
return $charset;
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38808';
$wp_version = '4.7-alpha-38809';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.