From d9266d5bfd6aed72907414728d83f1053c1c2a7a Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Thu, 28 Apr 2022 11:00:10 +0000 Subject: [PATCH] Media: Ensure `wp_read_image_metadata` filter returns array for `$iptc` and `$exif`. Makes the behavior of the filter lines up with its documentation. Previously, both `$iptc` and `$exif` could return `false` when `exif_read_data()` or `iptcparse()` failed. Now, if those functions do not return an array, the results are explicitly set to `array()`. Props volodymyrkolesnykov, SergeyBiryukov, sabernhardt, sumitsingh, mikeschroder. Fixes #54637. Built from https://develop.svn.wordpress.org/trunk@53303 git-svn-id: http://core.svn.wordpress.org/trunk@52892 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/image.php | 8 ++++++++ wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 136f6dcdab..74d08bf634 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -776,6 +776,10 @@ function wp_read_image_metadata( $file ) { $iptc = @iptcparse( $info['APP13'] ); } + if ( ! is_array( $iptc ) ) { + $iptc = array(); + } + // Headline, "A brief synopsis of the caption". if ( ! empty( $iptc['2#105'][0] ) ) { $meta['title'] = trim( $iptc['2#105'][0] ); @@ -845,6 +849,10 @@ function wp_read_image_metadata( $file ) { $exif = @exif_read_data( $file ); } + if ( ! is_array( $exif ) ) { + $exif = array(); + } + if ( ! empty( $exif['ImageDescription'] ) ) { mbstring_binary_safe_encoding(); $description_length = strlen( $exif['ImageDescription'] ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 57bc39c334..16ce207640 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-beta3-53302'; +$wp_version = '6.0-beta3-53303'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.