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

@ -5250,13 +5250,15 @@ function get_tag_regex( $tag ) {
* @return string The canonical form of the charset. * @return string The canonical form of the charset.
*/ */
function _canonical_charset( $charset ) { function _canonical_charset( $charset ) {
if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset || if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset) ) {
'UTF8' === $charset )
return 'UTF-8'; 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 'ISO-8859-1';
}
return $charset; return $charset;
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.