Multisite: Use case-insensitive check on email domain whitelist.
Props greatislander. Fixes #43148. git-svn-id: https://develop.svn.wordpress.org/trunk@42858 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6f408cf561
commit
4902da091c
|
@ -497,8 +497,9 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
|
|||
|
||||
$limited_email_domains = get_site_option( 'limited_email_domains' );
|
||||
if ( is_array( $limited_email_domains ) && ! empty( $limited_email_domains ) ) {
|
||||
$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
|
||||
if ( ! in_array( $emaildomain, $limited_email_domains ) ) {
|
||||
$limited_email_domains = array_map( 'strtolower', $limited_email_domains );
|
||||
$emaildomain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
|
||||
if ( ! in_array( $emaildomain, $limited_email_domains, true ) ) {
|
||||
$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,14 @@ if ( is_multisite() ) :
|
|||
$this->assertContains( 'user_email', $v['errors']->get_error_codes() );
|
||||
}
|
||||
|
||||
public function test_should_not_fail_for_emails_from_whitelisted_domains_with_mixed_case() {
|
||||
$domains = array( 'foo.com', 'bar.org' );
|
||||
update_site_option( 'limited_email_domains', $domains );
|
||||
|
||||
$v = wpmu_validate_user_signup( 'foo123', 'foo@BAR.org' );
|
||||
$this->assertNotContains( 'user_email', $v['errors']->get_error_codes() );
|
||||
}
|
||||
|
||||
public function test_should_fail_for_existing_user_name() {
|
||||
$u = self::factory()->user->create( array( 'user_login' => 'foo123' ) );
|
||||
$v = wpmu_validate_user_signup( 'foo123', 'foo@example.com' );
|
||||
|
|
Loading…
Reference in New Issue