From d30cc780fde9f76bd2ededf9a28284fddd772ef6 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Tue, 15 Oct 2024 22:24:18 +0000 Subject: [PATCH] Feeds: Validate enclosures prior to generating tags. Prevent possible PHP warnings caused by malformed enclosure meta data. This change ensures the enclosure meta data has at least three lines of text before generating the tag in `rss_enclosure()`. Props arypneta, johnjamesjacoby, nihar007, rahmohn, rghedin, zahardoc. Fixes #58798. Built from https://develop.svn.wordpress.org/trunk@59241 git-svn-id: http://core.svn.wordpress.org/trunk@58633 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/feed.php | 4 ++++ wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 7ef7059ce4..810abfee6f 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -482,6 +482,10 @@ function rss_enclosure() { foreach ( (array) $val as $enc ) { $enclosure = explode( "\n", $enc ); + if ( count( $enclosure ) < 3 ) { + continue; + } + // Only get the first element, e.g. 'audio/mpeg' from 'audio/mpeg mpga mp2 mp3'. $t = preg_split( '/[ \t]/', trim( $enclosure[2] ) ); $type = $t[0]; diff --git a/wp-includes/version.php b/wp-includes/version.php index 0498e78083..c8db80d52b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.7-beta3-59240'; +$wp_version = '6.7-beta3-59241'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.