WordPress.org

Make WordPress Core

Ticket #44949: 44949.3.patch

File 44949.3.patch, 830 bytes (added by jason_the_adams, 3 years ago)
  • src/wp-includes/rest-api.php

    diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
    index 0cce9fa62f..7d4abca3dd 100644
    a b function rest_validate_value_from_schema( $value, $args, $param = '' ) { 
    11441144                return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'string' ) );
    11451145        }
    11461146
     1147        if ( 'string' === $args['type'] && ! empty( $args['pattern'] ) ) {
     1148            $pattern = preg_quote( $args['patttern'], '/' );
     1149            if ( ! preg_match( preg_quote( "/{$pattern}/u" ), $value ) ) {
     1150                    return new WP_Error( 'rest_invalid_pattern', sprintf( __( '%1$s does not match pattern %s$s.' ), $param, $args['pattern'] ) );
     1151        }
     1152    }
     1153
    11471154        if ( isset( $args['format'] ) ) {
    11481155                switch ( $args['format'] ) {
    11491156                        case 'date-time':