Make WordPress Core


Ignore:
Timestamp:
04/11/2022 07:58:04 PM (2 years ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/formatting.php

    r53053 r53144  
    46404640        $regex,
    46414641        static function( $matches ) {
    4642             if ( ! $matches[0] ) {
     4642            if ( ! isset( $matches[0] ) ) {
    46434643                return '';
    46444644            }
    46454645
    4646             if ( ! empty( $matches['non_cdata'] ) ) {
     4646            if ( isset( $matches['non_cdata'] ) ) {
    46474647                // escape HTML entities in the non-CDATA Section.
    46484648                return _wp_specialchars( $matches['non_cdata'], ENT_XML1 );
Note: See TracChangeset for help on using the changeset viewer.