diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 4236249fca..fb418c1d45 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -289,11 +289,16 @@ function wp_read_image_metadata( $file ) { if ( ! empty( $iptc['2#120'][0] ) ) { // description / legacy caption $caption = trim( $iptc['2#120'][0] ); if ( empty( $meta['title'] ) ) { + mbstring_binary_safe_encoding(); + $caption_length = strlen( $caption ); + reset_mbstring_encoding(); + // Assume the title is stored in 2:120 if it's short. - if ( mbstring_binary_safe_strlen( $caption ) < 80 ) + if ( $caption_length < 80 ) { $meta['title'] = $caption; - else + } else { $meta['caption'] = $caption; + } } elseif ( $caption != $meta['title'] ) { $meta['caption'] = $caption; } @@ -327,7 +332,11 @@ function wp_read_image_metadata( $file ) { } if ( ! empty( $exif['ImageDescription'] ) ) { - if ( empty( $meta['title'] ) && mbstring_binary_safe_strlen( $exif['ImageDescription'] ) < 80 ) { + mbstring_binary_safe_encoding(); + $description_length = strlen( $exif['ImageDescription'] ); + reset_mbstring_encoding(); + + if ( empty( $meta['title'] ) && $description_length < 80 ) { // Assume the title is stored in ImageDescription $meta['title'] = trim( $exif['ImageDescription'] ); if ( empty( $meta['caption'] ) && ! empty( $exif['COMPUTED']['UserComment'] ) && trim( $exif['COMPUTED']['UserComment'] ) != $meta['title'] ) { diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 3b213931cf..77dee0f505 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -481,7 +481,9 @@ function shortcode_unautop( $pee ) { * @return bool True if $str fits a UTF-8 model, false otherwise. */ function seems_utf8($str) { - $length = mbstring_binary_safe_strlen($str); + mbstring_binary_safe_encoding(); + $length = strlen($str); + reset_mbstring_encoding(); for ($i=0; $i < $length; $i++) { $c = ord($str[$i]); if ($c < 0x80) $n = 0; # 0bbbbbbb @@ -705,7 +707,10 @@ function utf8_uri_encode( $utf8_string, $length = 0 ) { $num_octets = 1; $unicode_length = 0; - $string_length = mbstring_binary_safe_strlen( $utf8_string ); + mbstring_binary_safe_encoding(); + $string_length = strlen( $utf8_string ); + reset_mbstring_encoding(); + for ($i = 0; $i < $string_length; $i++ ) { $value = ord( $utf8_string[ $i ] ); diff --git a/wp-includes/functions.php b/wp-includes/functions.php index a4ad1fe567..33ace4283b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -4404,24 +4404,6 @@ function reset_mbstring_encoding() { mbstring_binary_safe_encoding( true ); } -/** - * Uses a binary-safe encoding to get the length of a string in bytes if func_overload is enabled. - * - * @see mbstring_binary_safe_encoding() - * - * @since 4.0.0 - * - * @param string $string The string to get the length of. - * @return int The length of the string in bytes. - */ -function mbstring_binary_safe_strlen( $string ) { - mbstring_binary_safe_encoding(); - $length = strlen( $string ); - reset_mbstring_encoding(); - - return $length; -} - /** * Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN ) *