Media: In wp_read_image_metadata() make sure that IPTC keywords are UTF8 encoded.

Prevents missing `_wp_attachment_metadata` when an image contains keywords with latin extended characters.

Merges [36429] to the 4.4 branch.
See #35316.

git-svn-id: https://develop.svn.wordpress.org/branches/4.4@36430 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dominik Schilling (ocean90) 2016-02-01 14:57:53 +00:00
parent 466dbe864c
commit 06b672cb34
2 changed files with 18 additions and 3 deletions

View File

@ -408,12 +408,14 @@ function wp_read_image_metadata( $file ) {
} }
} }
foreach ( $meta as &$value ) { foreach ( $meta['keywords'] as $key => $keyword ) {
if ( is_string( $value ) ) { if ( ! seems_utf8( $keyword ) ) {
$value = wp_kses_post( $value ); $meta['keywords'][ $key ] = utf8_encode( $keyword );
} }
} }
$meta = wp_kses_post_deep( $meta );
/** /**
* Filter the array of meta data read from an image's exif data. * Filter the array of meta data read from an image's exif data.
* *

View File

@ -1580,6 +1580,19 @@ function wp_kses_post( $data ) {
return wp_kses( $data, 'post' ); return wp_kses( $data, 'post' );
} }
/**
* Navigates through an array, object, or scalar, and sanitizes content for
* allowed HTML tags for post content.
*
* @since 4.4.2
*
* @param mixed $value The array or string to filter.
* @return mixed $value The filtered content.
*/
function wp_kses_post_deep( $data ) {
return map_deep( $data, 'wp_kses_post' );
}
/** /**
* Strips all of the HTML in the content. * Strips all of the HTML in the content.
* *