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 ) { |
966 | 966 | return strtotime( $date ); |
967 | 967 | } |
968 | 968 | |
| 969 | /** |
| 970 | * Sanitize email. |
| 971 | * |
| 972 | * @since 5.4.0 |
| 973 | * |
| 974 | * @param string $email Email address |
| 975 | * @return string Valid email address. |
| 976 | */ |
| 977 | function rest_sanitize_email( $email ) { |
| 978 | $email = sanitize_text_field( $email ); |
| 979 | |
| 980 | return filter_var( $email, FILTER_SANITIZE_EMAIL ); |
| 981 | } |
| 982 | |
969 | 983 | /** |
970 | 984 | * Parses a date into both its local and UTC equivalent, in MySQL datetime format. |
971 | 985 | * |
… |
… |
function rest_sanitize_value_from_schema( $value, $args ) { |
1477 | 1491 | /* |
1478 | 1492 | * sanitize_email() validates, which would be unexpected. |
1479 | 1493 | */ |
1480 | | return sanitize_text_field( $value ); |
| 1494 | return rest_sanitize_email( $value ); |
1481 | 1495 | |
1482 | 1496 | case 'uri': |
1483 | 1497 | return esc_url_raw( $value ); |
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 { |
62 | 62 | 'format' => 'email', |
63 | 63 | ); |
64 | 64 | $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 ) ); |
65 | 68 | $this->assertEquals( 'a@b.c', rest_sanitize_value_from_schema( 'a@b.c', $schema ) ); |
66 | 69 | $this->assertEquals( 'invalid', rest_sanitize_value_from_schema( 'invalid', $schema ) ); |
67 | 70 | } |
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 { |
198 | 198 | /** |
199 | 199 | * Should include relevant data in the 'theme_supports' key. |
200 | 200 | * |
| 201 | * |
201 | 202 | * @ticket 45016 |
202 | 203 | */ |
203 | 204 | public function test_theme_supports_formats() { |