Media: Prevent fatal error if metadata is an array.

Check the data type of ID3 data on import before running `wp_kses_post` or `wp_kses_post_deep` to fix a fatal error thrown when attempting to run `wp_kses_post` on non-string content in PHP 8.2+.

Adds unit tests to verify.

Props sllimrovert, ankitkumarshah, rollybueno, wpfy, hmbashar, SirLouen, johnbillion, huzaifaalmesbah, sandeepdahiya, sourabhjain, poojapadamad, joedolson.
Fixes #63529.
Built from https://develop.svn.wordpress.org/trunk@61098


git-svn-id: http://core.svn.wordpress.org/trunk@60434 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
joedolson
2025-10-30 19:45:32 +00:00
parent a6e40f4437
commit 96dcb2b13c
2 changed files with 2 additions and 2 deletions

View File

@@ -3534,7 +3534,7 @@ function wp_add_id3_tag_data( &$metadata, $data ) {
if ( ! empty( $data[ $version ]['comments'] ) ) {
foreach ( $data[ $version ]['comments'] as $key => $list ) {
if ( 'length' !== $key && ! empty( $list ) ) {
$metadata[ $key ] = wp_kses_post( reset( $list ) );
$metadata[ $key ] = is_array( $list ) ? wp_kses_post_deep( reset( $list ) ) : wp_kses_post( $list );
// Fix bug in byte stream analysis.
if ( 'terms_of_use' === $key && str_starts_with( $metadata[ $key ], 'yright notice.' ) ) {
$metadata[ $key ] = 'Cop' . $metadata[ $key ];

View File

@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.9-beta2-61097';
$wp_version = '6.9-beta2-61098';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.