From 761af68257feeae4b6253530ee1e1349da35c253 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Thu, 17 Sep 2026 15:57:19 +0530 Subject: [PATCH 1/3] Hoist loop-invariant calls out of get_the_category_rss() --- src/wp-includes/feed.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 453cc9063cf75..734d5fa0f70f8 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -406,13 +406,24 @@ function get_the_category_rss( $type = null ) { $cat_names = array_unique( $cat_names ); + $blog_charset = ''; + $atom_scheme = ''; + if ( ! empty( $cat_names ) ) { + if ( 'atom' === $type ) { + // Escaped here as the scheme is the same for every term in the loop below. + $atom_scheme = esc_attr( get_bloginfo_rss( 'url' ) ); + } elseif ( 'rdf' !== $type ) { + $blog_charset = get_option( 'blog_charset' ); + } + } + foreach ( $cat_names as $cat_name ) { if ( 'rdf' === $type ) { $the_list .= "\t\t\n"; } elseif ( 'atom' === $type ) { - $the_list .= sprintf( '', esc_attr( get_bloginfo_rss( 'url' ) ), esc_attr( $cat_name ) ); + $the_list .= sprintf( '', $atom_scheme, esc_attr( $cat_name ) ); } else { - $the_list .= "\t\t\n"; + $the_list .= "\t\t\n"; } } From a6f3c77996717e7a102bbe7183fbccfe2ee522ae Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 18 Sep 2026 08:34:58 +0530 Subject: [PATCH 2/3] Fix atom scheme escaping in feed.php --- src/wp-includes/feed.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index 734d5fa0f70f8..e13d05bb95c85 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -410,8 +410,7 @@ function get_the_category_rss( $type = null ) { $atom_scheme = ''; if ( ! empty( $cat_names ) ) { if ( 'atom' === $type ) { - // Escaped here as the scheme is the same for every term in the loop below. - $atom_scheme = esc_attr( get_bloginfo_rss( 'url' ) ); + $atom_scheme = get_bloginfo_rss( 'url' ); } elseif ( 'rdf' !== $type ) { $blog_charset = get_option( 'blog_charset' ); } @@ -421,7 +420,7 @@ function get_the_category_rss( $type = null ) { if ( 'rdf' === $type ) { $the_list .= "\t\t\n"; } elseif ( 'atom' === $type ) { - $the_list .= sprintf( '', $atom_scheme, esc_attr( $cat_name ) ); + $the_list .= sprintf( '', esc_attr( $atom_scheme ), esc_attr( $cat_name ) ); } else { $the_list .= "\t\t\n"; } From 71e4260bb3d3b1fc0b6cda6ec32ee51ccbb5f653 Mon Sep 17 00:00:00 2001 From: Mukesh Panchal Date: Fri, 18 Sep 2026 09:01:19 +0530 Subject: [PATCH 3/3] Avoid using empty() Co-authored-by: Weston Ruter --- src/wp-includes/feed.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/feed.php b/src/wp-includes/feed.php index e13d05bb95c85..b256ab3bcc348 100644 --- a/src/wp-includes/feed.php +++ b/src/wp-includes/feed.php @@ -408,7 +408,7 @@ function get_the_category_rss( $type = null ) { $blog_charset = ''; $atom_scheme = ''; - if ( ! empty( $cat_names ) ) { + if ( $cat_names ) { if ( 'atom' === $type ) { $atom_scheme = get_bloginfo_rss( 'url' ); } elseif ( 'rdf' !== $type ) {