mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
REST API: Sanitize arrays being sent as CSVs.
In #38586 the ability to parse arrays as csv was introduced, however it didn't add any support for validating csv arrays. This adds such sanitization, and also a good amount of unit tests for all sanitization baed off schema. See #38586. git-svn-id: https://develop.svn.wordpress.org/trunk@39061 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -1097,6 +1097,9 @@ function rest_sanitize_value_from_schema( $value, $args ) {
|
||||
if ( empty( $args['items'] ) ) {
|
||||
return (array) $value;
|
||||
}
|
||||
if ( ! is_array( $value ) ) {
|
||||
$value = preg_split( '/[\s,]+/', $value );
|
||||
}
|
||||
foreach ( $value as $index => $v ) {
|
||||
$value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'] );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user