From 98b994303e99b5bee4457f3c35fdbd4bc88cda49 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Mon, 1 Feb 2016 14:58:28 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/branches/4.4@36430 git-svn-id: http://core.svn.wordpress.org/branches/4.4@36397 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 8 +++++--- wp-includes/kses.php | 13 +++++++++++++ wp-includes/version.php | 2 +- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 139d405070..2faccfe71a 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -408,12 +408,14 @@ function wp_read_image_metadata( $file ) { } } - foreach ( $meta as &$value ) { - if ( is_string( $value ) ) { - $value = wp_kses_post( $value ); + foreach ( $meta['keywords'] as $key => $keyword ) { + if ( ! seems_utf8( $keyword ) ) { + $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. * diff --git a/wp-includes/kses.php b/wp-includes/kses.php index d34608b89f..4827b0de2c 100644 --- a/wp-includes/kses.php +++ b/wp-includes/kses.php @@ -1580,6 +1580,19 @@ function wp_kses_post( $data ) { 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. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 1a0c3b949b..8050ff5373 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4.2-alpha-36428'; +$wp_version = '4.4.2-alpha-36430'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.