Make WordPress Core

Ticket #27270: 27270.patch

File 27270.patch, 1.8 KB (added by jared_smith, 10 years ago)

Updated patch and unit test

  • src/wp-includes/formatting.php

     
    21462146                return apply_filters( 'is_email', false, $email, 'local_invalid_chars' );
    21472147        }
    21482148
    2149         // DOMAIN PART
    2150         // Test for sequences of periods
    2151         if ( preg_match( '/\.{2,}/', $domain ) ) {
     2149        // Test for sequences of periods in either the local part or domain part
     2150        if ( preg_match( '/\.{2,}/', $email) ) {
    21522151                /** This filter is documented in wp-includes/formatting.php */
    21532152                return apply_filters( 'is_email', false, $email, 'domain_period_sequence' );
    21542153        }
    21552154
    2156         // Test for leading and trailing periods and whitespace
    2157         if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain ) {
     2155        // Test for leading and trailing periods and whitespace in both local and domain parts
     2156        if ( trim( $domain, " \t\n\r\0\x0B." ) !== $domain || trim( $local, " \t\n\r\0\x0B." ) !== $local ) {
    21582157                /** This filter is documented in wp-includes/formatting.php */
    21592158                return apply_filters( 'is_email', false, $email, 'domain_period_limits' );
    21602159        }
    21612160
     2161        // DOMAIN PART
     2162
    21622163        // Split the domain into subs
    21632164        $subs = explode( '.', $domain );
    21642165
  • tests/phpunit/tests/formatting/IsEmail.php

     
    2222                        'http://bob.example.com/',
    2323                        "sif i'd give u it, spamer!1",
    2424                        "com.exampleNOSPAMbob",
    25                         "bob@your mom"
     25                        "bob@your mom",
     26                        ".bad.@example.com",
     27                        "two..periods@example.com"
    2628                        );
    2729                foreach ($data as $datum) {
    2830                        $this->assertFalse(is_email($datum), $datum);