WordPress.org

Make WordPress Core

Changeset 42858


Ignore:
Timestamp:
03/20/2018 07:06:09 PM (19 months ago)
Author:
jeremyfelt
Message:

Multisite: Use case-insensitive check on email domain whitelist.

Props greatislander.
Fixes #43148.

Location:
trunk
Files:
2 edited

Legend:

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

    r42827 r42858  
    498498    $limited_email_domains = get_site_option( 'limited_email_domains' );
    499499    if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
    500         $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
    501         if ( ! in_array( $emaildomain, $limited_email_domains ) ) {
     500        $limited_email_domains = array_map( 'strtolower', $limited_email_domains );
     501        $emaildomain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
     502        if ( ! in_array( $emaildomain, $limited_email_domains, true ) ) {
    502503            $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) );
    503504        }
  • trunk/tests/phpunit/tests/multisite/wpmuValidateUserSignup.php

    r42343 r42858  
    6161            $v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
    6262            $this->assertContains( 'user_email', $v['errors']->get_error_codes() );
     63        }
     64
     65        public function test_should_not_fail_for_emails_from_whitelisted_domains_with_mixed_case() {
     66            $domains = array( 'foo.com', 'bar.org' );
     67            update_site_option( 'limited_email_domains', $domains );
     68
     69            $v = wpmu_validate_user_signup( 'foo123', 'foo@BAR.org' );
     70            $this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
    6371        }
    6472
Note: See TracChangeset for help on using the changeset viewer.