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
This commit is contained in:
Gary Pendergast 2019-02-07 23:35:49 +00:00
parent a1eceec5bd
commit cddee8b72e
2 changed files with 4 additions and 2 deletions

View File

@ -5153,10 +5153,12 @@ function sanitize_textarea_field( $str ) {
* @return string Sanitized string. * @return string Sanitized string.
*/ */
function _sanitize_text_fields( $str, $keep_newlines = false ) { function _sanitize_text_fields( $str, $keep_newlines = false ) {
if ( ! is_string( $str ) ) { if ( is_object( $str ) || is_array( $str ) ) {
return ''; return '';
} }
$str = (string) $str;
$filtered = wp_check_invalid_utf8( $str ); $filtered = wp_check_invalid_utf8( $str );
if ( strpos( $filtered, '<' ) !== false ) { if ( strpos( $filtered, '<' ) !== false ) {

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.