Changeset 39158
- Timestamp:
- 11/08/2016 06:41:57 AM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api.php
r39061 r39158 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 } -
trunk/tests/phpunit/tests/rest-api/rest-comments-controller.php
r39157 r39158 907 907 908 908 update_option( 'require_name_email', 0 ); 909 } 910 911 public function test_create_comment_author_email_too_short() { 912 wp_set_current_user( 0 ); 913 914 $params = array( 915 'post' => self::$post_id, 916 'author_name' => 'Homer J. Simpson', 917 'author_email' => 'a@b', 918 'content' => 'in this house, we obey the laws of thermodynamics!', 919 ); 920 921 $request = new WP_REST_Request( 'POST', '/wp/v2/comments' ); 922 $request->add_header( 'content-type', 'application/json' ); 923 $request->set_body( wp_json_encode( $params ) ); 924 $response = $this->server->dispatch( $request ); 925 926 $this->assertErrorResponse( 'rest_invalid_param', $response, 400 ); 927 928 $data = $response->get_data(); 929 $this->assertArrayHasKey( 'author_email', $data['data']['params'] ); 909 930 } 910 931
Note: See TracChangeset
for help on using the changeset viewer.