Formatting: Increase minimum characters allowed in `is_email()` to 6.
Brings the minimum characters expected for a valid email address to six, which matches the expectations in `wp_handle_comment_submission()` and REST API email arguments. Props rmccue, lukecavanagh, rachelbaker, desrosj, sudar. Fixes #38708. git-svn-id: https://develop.svn.wordpress.org/trunk@40667 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f2ce983da0
commit
c52f1fb160
|
@ -3065,7 +3065,7 @@ function wp_handle_comment_submission( $comment_data ) {
|
||||||
$comment_type = '';
|
$comment_type = '';
|
||||||
|
|
||||||
if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
|
if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
|
||||||
if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
|
if ( '' == $comment_author_email || '' == $comment_author ) {
|
||||||
return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
|
return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
|
||||||
} elseif ( ! is_email( $comment_author_email ) ) {
|
} elseif ( ! is_email( $comment_author_email ) ) {
|
||||||
return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
|
return new WP_Error( 'require_valid_email', __( '<strong>ERROR</strong>: please enter a valid email address.' ), 200 );
|
||||||
|
|
|
@ -2872,7 +2872,7 @@ function is_email( $email, $deprecated = false ) {
|
||||||
_deprecated_argument( __FUNCTION__, '3.0.0' );
|
_deprecated_argument( __FUNCTION__, '3.0.0' );
|
||||||
|
|
||||||
// Test for the minimum length the email can be
|
// Test for the minimum length the email can be
|
||||||
if ( strlen( $email ) < 3 ) {
|
if ( strlen( $email ) < 6 ) {
|
||||||
/**
|
/**
|
||||||
* Filters whether an email address is valid.
|
* Filters whether an email address is valid.
|
||||||
*
|
*
|
||||||
|
@ -3109,7 +3109,7 @@ function iso8601_to_datetime( $date_string, $timezone = 'user' ) {
|
||||||
*/
|
*/
|
||||||
function sanitize_email( $email ) {
|
function sanitize_email( $email ) {
|
||||||
// Test for the minimum length the email can be
|
// Test for the minimum length the email can be
|
||||||
if ( strlen( $email ) < 3 ) {
|
if ( strlen( $email ) < 6 ) {
|
||||||
/**
|
/**
|
||||||
* Filters a sanitized email address.
|
* Filters a sanitized email address.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1077,11 +1077,7 @@ function rest_validate_value_from_schema( $value, $args, $param = '' ) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'email' :
|
case 'email' :
|
||||||
// is_email() checks for 3 characters (a@b), but
|
if ( ! is_email( $value ) ) {
|
||||||
// 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', __( 'Invalid email address.' ) );
|
return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -9,7 +9,8 @@ class Tests_Formatting_IsEmail extends WP_UnitTestCase {
|
||||||
"bob@example.com",
|
"bob@example.com",
|
||||||
"phil@example.info",
|
"phil@example.info",
|
||||||
"ace@204.32.222.14",
|
"ace@204.32.222.14",
|
||||||
"kevin@many.subdomains.make.a.happy.man.edu"
|
"kevin@many.subdomains.make.a.happy.man.edu",
|
||||||
|
"a@b.co",
|
||||||
);
|
);
|
||||||
foreach ( $data as $datum ) {
|
foreach ( $data as $datum ) {
|
||||||
$this->assertEquals( $datum, is_email( $datum ), $datum );
|
$this->assertEquals( $datum, is_email( $datum ), $datum );
|
||||||
|
@ -22,7 +23,8 @@ class Tests_Formatting_IsEmail extends WP_UnitTestCase {
|
||||||
'http://bob.example.com/',
|
'http://bob.example.com/',
|
||||||
"sif i'd give u it, spamer!1",
|
"sif i'd give u it, spamer!1",
|
||||||
"com.exampleNOSPAMbob",
|
"com.exampleNOSPAMbob",
|
||||||
"bob@your mom"
|
"bob@your mom",
|
||||||
|
"a@b.c",
|
||||||
);
|
);
|
||||||
foreach ($data as $datum) {
|
foreach ($data as $datum) {
|
||||||
$this->assertFalse(is_email($datum), $datum);
|
$this->assertFalse(is_email($datum), $datum);
|
||||||
|
|
Loading…
Reference in New Issue