Make WordPress Core

Ticket #15706: 15706.patch

File 15706.patch, 1.2 KB (added by SergeyBiryukov, 14 years ago)
  • wp-includes/ms-functions.php

     
    564564        $limited_email_domains = get_site_option( 'limited_email_domains' );
    565565        if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
    566566                $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
    567                 if ( in_array( $emaildomain, $limited_email_domains ) == false )
     567                $matched_domain = false;
     568
     569                foreach ( $limited_email_domains as $limited_domain ) {
     570                        if ( 0 === strpos( $limited_domain, '*.' ) ) {
     571                                // Allow all subdomains for this limited domain. Nick off the '*.' and do a more expansive match.
     572                                $local_limited_domain = substr( $limited_domain, 2 );
     573                                if ( substr( $emaildomain, strlen( $emaildomain ) - strlen( $local_limited_domain ) ) == $local_limited_domain ) {
     574                                        $matched_domain = true;
     575                                        break;
     576                                }
     577                        } elseif ( $emaildomain == $limited_domain ) {
     578                                // Direct domain match
     579                                $matched_domain = true;
     580                                break;
     581                        }
     582                }
     583
     584                if ( ! $matched_domain )
    568585                        $errors->add('user_email', __('Sorry, that email address is not allowed!'));
    569586        }
    570587