From 06a25caf2327bd875a78941c79f4847c2779fce8 Mon Sep 17 00:00:00 2001 From: dmsnell Date: Tue, 14 May 2024 18:07:07 +0000 Subject: [PATCH] Quick-fix: Normalize UTF-8 charset slug detection. In the merge of [58417] the new file was missed. This commit adds the missing required file. Developed in https://github.com/WordPress/wordpress-develop/pull/6535 Discussed in https://core.trac.wordpress.org/ticket/61182 Fixes #61182. Follow-up to [58147]. Props dmsnell, jonsurrell. Built from https://develop.svn.wordpress.org/trunk@58148 git-svn-id: http://core.svn.wordpress.org/trunk@57613 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/unicode.php | 51 +++++++++++++++++++++++++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 wp-includes/unicode.php diff --git a/wp-includes/unicode.php b/wp-includes/unicode.php new file mode 100644 index 0000000000..5348e49789 --- /dev/null +++ b/wp-includes/unicode.php @@ -0,0 +1,51 @@ + 'utf-8' ] ); + * + * // Without a given charset, it depends on the site option "blog_charset". + * $is_utf8 = is_utf8_charset(); + * + * @since 6.6.0 + * + * @param ?string $blog_charset Slug representing a text character encoding, or "charset". + * E.g. "UTF-8", "Windows-1252", "ISO-8859-1", "SJIS". + * @return bool Whether the slug represents the UTF-8 encoding. + */ +function is_utf8_charset( $blog_charset = null ) { + $charset_to_examine = $blog_charset ?? get_option( 'blog_charset' ); + + /* + * Only valid string values count: the absence of a charset + * does not imply any charset, let alone UTF-8. + */ + if ( ! is_string( $charset_to_examine ) ) { + return false; + } + + return ( + 0 === strcasecmp( 'UTF-8', $charset_to_examine ) || + 0 === strcasecmp( 'UTF8', $charset_to_examine ) + ); +} diff --git a/wp-includes/version.php b/wp-includes/version.php index 418dcc4f9a..7cfdf0a6d0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58147'; +$wp_version = '6.6-alpha-58148'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.