From 70dea8e3c2ca16cea21447a631e9ded2155eae03 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Mon, 11 Apr 2022 20:00:09 +0000 Subject: [PATCH] Formatting: Avoid escaping valid XML values in `esc_xml()`. This change improves the `esc_xml()` function by replacing two `empty()` checks with `isset()` to cover values that are not equal to `''` but still returning `true` when checked with `empty()`, like `'0'`, `0` or `false`. It also updates the related unit tests accordingly. Props rumpel2116, pbiron. Fixes #55399. Built from https://develop.svn.wordpress.org/trunk@53144 git-svn-id: http://core.svn.wordpress.org/trunk@52733 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 4 ++-- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 0441866344..eb4acda64b 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -4639,11 +4639,11 @@ EOF; $safe_text = (string) preg_replace_callback( $regex, static function( $matches ) { - if ( ! $matches[0] ) { + if ( ! isset( $matches[0] ) ) { return ''; } - if ( ! empty( $matches['non_cdata'] ) ) { + if ( isset( $matches['non_cdata'] ) ) { // escape HTML entities in the non-CDATA Section. return _wp_specialchars( $matches['non_cdata'], ENT_XML1 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index c3e0c5e681..5df481479f 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.0-alpha-53143'; +$wp_version = '6.0-alpha-53144'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.