Remove mbstring_binary_safe_strlen(). Use mbstring_binary_safe_encoding() and reset_mbstring_encoding() directly.

fixes #28162.
Built from https://develop.svn.wordpress.org/trunk@28808


git-svn-id: http://core.svn.wordpress.org/trunk@28617 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2014-06-23 22:21:15 +00:00
parent 54915274fa
commit 8b272f4379
3 changed files with 19 additions and 23 deletions

View File

@ -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'] ) {

View File

@ -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 ] );

View File

@ -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 )
*