From d9ea7a47cbf1143d0486282fddb69295a35cc9ab Mon Sep 17 00:00:00 2001 From: Thomas Bensmann Date: Thu, 21 Dec 2023 12:14:47 +0100 Subject: [PATCH 1/2] Only apply normalize_whitespace to string --- src/wp-includes/formatting.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index bc150c8a537cb..ce8311cc0d0a0 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -5503,6 +5503,10 @@ function _links_add_target( $m ) { * @return string The normalized string. */ function normalize_whitespace( $str ) { + if( !is_string( $str ) ) { + return $str; + } + $str = trim( $str ); $str = str_replace( "\r", "\n", $str ); $str = preg_replace( array( '/\n+/', '/[ \t]+/' ), array( "\n", ' ' ), $str ); From 01d9788a8bec0c348c287b5f994f58cd73930e51 Mon Sep 17 00:00:00 2001 From: Thomas Bensmann Date: Thu, 21 Dec 2023 12:30:01 +0100 Subject: [PATCH 2/2] fix: coding standards --- src/wp-includes/formatting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index ce8311cc0d0a0..2f9f88f2acf5c 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -5503,7 +5503,7 @@ function _links_add_target( $m ) { * @return string The normalized string. */ function normalize_whitespace( $str ) { - if( !is_string( $str ) ) { + if ( ! is_string( $str ) ) { return $str; }