Ticket #38506: 38506.2.diff
File 38506.2.diff, 1.8 KB (added by , 9 years ago) |
---|
-
src/wp-includes/rest-api.php
1036 1036 break; 1037 1037 1038 1038 case 'email' : 1039 if ( ! is_email( $value ) ) { 1039 // is_email() checks for 3 characters (a@b), but 1040 // wp_handle_comment_submission() requires 6 characters (a@b.co) 1041 // 1042 // https://core.trac.wordpress.org/ticket/38506 1043 if ( ! is_email( $value ) || strlen( $value ) < 6 ) { 1040 1044 return new WP_Error( 'rest_invalid_email', __( 'The email address you provided is invalid.' ) ); 1041 1045 } 1042 1046 break; -
tests/phpunit/tests/rest-api/rest-comments-controller.php
897 897 update_option( 'require_name_email', 0 ); 898 898 } 899 899 900 public function test_create_comment_author_email_too_short() { 901 wp_set_current_user( 0 ); 902 903 $params = array( 904 'post' => self::$post_id, 905 'author_name' => 'Homer J. Simpson', 906 'author_email' => 'a@b', 907 'content' => 'in this house, we obey the laws of thermodynamics!', 908 ); 909 910 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 911 $request->add_header( 'content-type', 'application/json' ); 912 $request->set_body( wp_json_encode( $params ) ); 913 $response = $this->server->dispatch( $request ); 914 915 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 916 917 $data = $response->get_data(); 918 $this->assertArrayHasKey( 'author_email', $data['data']['params'] ); 919 } 920 900 921 public function test_create_item_invalid_blank_content() { 901 922 wp_set_current_user( 0 ); 902 923