WordPress.org

Make WordPress Core

Ticket #44949: 44949.2.patch

File 44949.2.patch, 762 bytes (added by jason_the_adams, 3 years ago)

Last diff was wrong direction, this adds

  • src/wp-includes/rest-api.php

    diff --git a/src/wp-includes/rest-api.php b/src/wp-includes/rest-api.php
    index 0cce9fa62f..26ca9297ff 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            if ( ! preg_match( $args['pattern'], $value ) ) {
     1149                    return new WP_Error( 'rest_invalid_pattern', sprintf( __( '%1$s does not match pattern %s$s.' ), $param, $args['pattern'] ) );
     1150        }
     1151    }
     1152
    11471153        if ( isset( $args['format'] ) ) {
    11481154                switch ( $args['format'] ) {
    11491155                        case 'date-time':