From cddee8b72e59c9968b1c786c01992dae6f71ee13 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 7 Feb 2019 23:35:49 +0000 Subject: [PATCH] Formatting: Loosen the type checking in `_sanitize_text_fields()`. [44618] added strict type checking to `_sanitize_text_fields()`, which has caused some compat issues with plugins. We can loosen the type checking to only reject objects and arrays, and cast other types to string. Props Nick_theGeek, pento. Fixes #41450. Built from https://develop.svn.wordpress.org/trunk@44731 git-svn-id: http://core.svn.wordpress.org/trunk@44562 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/formatting.php | 4 +++- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index f9a985e864..41747ebdef 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -5153,10 +5153,12 @@ function sanitize_textarea_field( $str ) { * @return string Sanitized string. */ function _sanitize_text_fields( $str, $keep_newlines = false ) { - if ( ! is_string( $str ) ) { + if ( is_object( $str ) || is_array( $str ) ) { return ''; } + $str = (string) $str; + $filtered = wp_check_invalid_utf8( $str ); if ( strpos( $filtered, '<' ) !== false ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index a591417cbf..0250385421 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.1-beta3-44730'; +$wp_version = '5.1-beta3-44731'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.