Make WordPress Core

Changeset 40667


Ignore:
Timestamp:
05/14/2017 04:19:51 AM (7 years ago)
Author:
rachelbaker
Message:

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.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/comment.php

    r40664 r40667  
    30663066
    30673067    if ( get_option( 'require_name_email' ) && ! $user->exists() ) {
    3068         if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
     3068        if ( '' == $comment_author_email || '' == $comment_author ) {
    30693069            return new WP_Error( 'require_name_email', __( '<strong>ERROR</strong>: please fill the required fields (name, email).' ), 200 );
    30703070        } elseif ( ! is_email( $comment_author_email ) ) {
  • trunk/src/wp-includes/formatting.php

    r40626 r40667  
    28732873
    28742874    // Test for the minimum length the email can be
    2875     if ( strlen( $email ) < 3 ) {
     2875    if ( strlen( $email ) < 6 ) {
    28762876        /**
    28772877         * Filters whether an email address is valid.
     
    31103110function sanitize_email( $email ) {
    31113111    // Test for the minimum length the email can be
    3112     if ( strlen( $email ) < 3 ) {
     3112    if ( strlen( $email ) < 6 ) {
    31133113        /**
    31143114         * Filters a sanitized email address.
  • trunk/src/wp-includes/rest-api.php

    r40600 r40667  
    10781078
    10791079            case 'email' :
    1080                 // is_email() checks for 3 characters (a@b), but
    1081                 // wp_handle_comment_submission() requires 6 characters (a@b.co)
    1082                 //
    1083                 // https://core.trac.wordpress.org/ticket/38506
    1084                 if ( ! is_email( $value ) || strlen( $value ) < 6 ) {
     1080                if ( ! is_email( $value ) ) {
    10851081                    return new WP_Error( 'rest_invalid_email', __( 'Invalid email address.' ) );
    10861082                }
  • trunk/tests/phpunit/tests/formatting/IsEmail.php

    r30392 r40667  
    1010            "phil@example.info",
    1111            "ace@204.32.222.14",
    12             "kevin@many.subdomains.make.a.happy.man.edu"
     12            "kevin@many.subdomains.make.a.happy.man.edu",
     13            "a@b.co",
    1314            );
    1415        foreach ( $data as $datum ) {
     
    2324            "sif i'd give u it, spamer!1",
    2425            "com.exampleNOSPAMbob",
    25             "bob@your mom"
     26            "bob@your mom",
     27            "a@b.c",
    2628            );
    2729        foreach ($data as $datum) {
Note: See TracChangeset for help on using the changeset viewer.