WordPress.org

Make WordPress Core

Changeset 25197


Ignore:
Timestamp:
08/31/2013 04:35:15 AM (7 years ago)
Author:
nacin
Message:

Case insensitivity for is_email_address_unsafe().

props jkudish.
fixes #25046.

Location:
trunk
Files:
2 edited

Legend:

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

    r25183 r25197  
    380380
    381381    if ( $banned_names && is_array( $banned_names ) ) {
    382         list( $email_local_part, $email_domain ) = explode( '@', $user_email );
     382        $banned_names = array_map( 'strtolower', $banned_names );
     383        $normalized_email = strtolower( $user_email );
     384
     385        list( $email_local_part, $email_domain ) = explode( '@', $normalized_email );
    383386
    384387        foreach ( $banned_names as $banned_domain ) {
     
    392395
    393396            $dotted_domain = ".$banned_domain";
    394             if ( $dotted_domain === substr( $user_email, -strlen( $dotted_domain ) ) ) {
     397            if ( $dotted_domain === substr( $normalized_email, -strlen( $dotted_domain ) ) ) {
    395398                $is_email_address_unsafe = true;
    396399                break;
  • trunk/tests/phpunit/tests/ms.php

    r25111 r25197  
    828828     * @ticket 21570
    829829     */
    830     function test_is_email_address_unsafe() {
     830    function test_aggressiveness_of_is_email_address_unsafe() {
    831831        update_site_option( 'banned_email_domains', array( 'bar.com', 'foo.co' ) );
    832832
     
    840840    }
    841841
     842    /**
     843     * @ticket 25046
     844     */
     845    function test_case_sensitivity_of_is_email_address_unsafe() {
     846        update_site_option( 'banned_email_domains', array( 'baR.com', 'Foo.co', 'barfoo.COM', 'BAZ.com' ) );
     847
     848        foreach ( array( 'test@Bar.com', 'tEst@bar.com', 'test@barFoo.com', 'tEst@foo.bar.com', 'test@baz.Com' ) as $email_address ) {
     849            $this->assertTrue( is_email_address_unsafe( $email_address ), "$email_address should be UNSAFE" );
     850        }
     851
     852        foreach ( array( 'test@Foobar.com', 'test@Foo-bar.com', 'tEst@foobar.com', 'test@Subdomain.Foo.com', 'test@fooBAz.com' ) as $email_address ) {
     853            $this->assertFalse( is_email_address_unsafe( $email_address ), "$email_address should be SAFE" );
     854        }
     855
     856    }
    842857    /**
    843858     * @ticket 21552
Note: See TracChangeset for help on using the changeset viewer.