REST API: Require 6 characters for comment email addresses.

The regular comments API requires 6 characters rather than 3, so we need to match this.

Props mangeshp, dd32.
Fixes #38506.


git-svn-id: https://develop.svn.wordpress.org/trunk@39158 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan McCue
2016-11-08 06:41:57 +00:00
parent e74994b2f4
commit 08efd7b636
2 changed files with 26 additions and 1 deletions

View File

@@ -1036,7 +1036,11 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
break;
case 'email' :
if ( ! is_email( $value ) ) {
// is_email() checks for 3 characters (a@b), but
// wp_handle_comment_submission() requires 6 characters (a@b.co)
//
// https://core.trac.wordpress.org/ticket/38506
if ( ! is_email( $value ) || strlen( $value ) < 6 ) {
return new WP_Error( 'rest_invalid_email', __( 'The email address you provided is invalid.' ) );
}
break;