Make WordPress Core

Ticket #49277: 49277.diff

File 49277.diff, 2.5 KB (added by spacedmonkey, 5 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 8fbf4b1342..baf6683fe2 100644
    a b function rest_parse_date( $date, $force_utc = false ) { 
    966966        return strtotime( $date );
    967967}
    968968
     969/**
     970 * Sanitize email.
     971 *
     972 * @since 5.4.0
     973 *
     974 * @param string $email Email address
     975 * @return string Valid email address.
     976 */
     977function rest_sanitize_email( $email ) {
     978        $email = sanitize_text_field( $email );
     979
     980        return filter_var( $email, FILTER_SANITIZE_EMAIL );
     981}
     982
    969983/**
    970984 * Parses a date into both its local and UTC equivalent, in MySQL datetime format.
    971985 *
    function rest_sanitize_value_from_schema( $value, $args ) { 
    14771491                                /*
    14781492                                 * sanitize_email() validates, which would be unexpected.
    14791493                                 */
    1480                                 return sanitize_text_field( $value );
     1494                                return rest_sanitize_email( $value );
    14811495
    14821496                        case 'uri':
    14831497                                return esc_url_raw( $value );
  • tests/phpunit/tests/rest-api/rest-schema-sanitization.php

    diff --git a/tests/phpunit/tests/rest-api/rest-schema-sanitization.php b/tests/phpunit/tests/rest-api/rest-schema-sanitization.php
    index 1b2fd1d90c..2bb002180a 100644
    a b class WP_Test_REST_Schema_Sanitization extends WP_UnitTestCase { 
    6262                        'format' => 'email',
    6363                );
    6464                $this->assertEquals( 'email@example.com', rest_sanitize_value_from_schema( 'email@example.com', $schema ) );
     65                $this->assertEquals( 'email@example.com', rest_sanitize_value_from_schema( 'email🙂@example.com', $schema ) );
     66                $this->assertEquals( 'email@example.com', rest_sanitize_value_from_schema( '±email@example.com', $schema ) );
     67                $this->assertEquals( 'email@example.com', rest_sanitize_value_from_schema( '(email@example.com)', $schema ) );
    6568                $this->assertEquals( 'a@b.c', rest_sanitize_value_from_schema( 'a@b.c', $schema ) );
    6669                $this->assertEquals( 'invalid', rest_sanitize_value_from_schema( 'invalid', $schema ) );
    6770        }
  • tests/phpunit/tests/rest-api/rest-themes-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-themes-controller.php b/tests/phpunit/tests/rest-api/rest-themes-controller.php
    index 520dbed9d0..2f82c7e0fa 100644
    a b class WP_Test_REST_Themes_Controller extends WP_Test_REST_Controller_Testcase { 
    198198        /**
    199199         * Should include relevant data in the 'theme_supports' key.
    200200         *
     201         *
    201202         * @ticket 45016
    202203         */
    203204        public function test_theme_supports_formats() {