Bootstrap/Load: Make sure add_magic_quotes() does not inappropriately recast non-string data types to string.

Props donmhico, jrf, Veraxus, Rarst.
Fixes #48605.

git-svn-id: https://develop.svn.wordpress.org/trunk@48205 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-06-28 21:02:18 +00:00
parent 5289a345cf
commit e5e4f0d977
2 changed files with 68 additions and 0 deletions
+4
View File
@@ -1219,6 +1219,7 @@ function wp_removable_query_args() {
* Walks the array while sanitizing the contents.
*
* @since 0.71
* @since 5.5.0 Non-string values are left untouched.
*
* @param array $array Array to walk while sanitizing contents.
* @return array Sanitized $array.
@@ -1227,10 +1228,13 @@ function add_magic_quotes( $array ) {
foreach ( (array) $array as $k => $v ) {
if ( is_array( $v ) ) {
$array[ $k ] = add_magic_quotes( $v );
} elseif ( ! is_string( $v ) ) {
continue;
} else {
$array[ $k ] = addslashes( $v );
}
}
return $array;
}