Skip to content

Commit

Permalink
Limited domain checks should not be case sensitive.
Browse files Browse the repository at this point in the history
  • Loading branch information
boonebgorges committed Sep 18, 2015
1 parent e65a39f commit 00f9e63
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 11 additions & 2 deletions by-email/by-email.php
Expand Up @@ -1410,8 +1410,17 @@ function invite_anyone_validate_email( $user_email ) {
if ( function_exists( 'get_site_option' ) ) {
if ( $limited_email_domains = get_site_option( 'limited_email_domains' ) ) {
if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
if( in_array( $emaildomain, $limited_email_domains ) == false ) {
$emaildomain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );

$is_valid_domain = false;
foreach ( $limited_email_domains as $led ) {
if ( $emaildomain === strtolower( $led ) ) {
$is_valid_domain = true;
break;
}
}

if ( ! $is_valid_domain ) {
$status = 'limited_domain';
}
}
Expand Down
12 changes: 12 additions & 0 deletions tests/testcases/test-sample.php
Expand Up @@ -93,5 +93,17 @@ public function test_group_access_test_friends() {

bp_update_option( 'invite_anyone', $settings );
}

public function test_invite_anyone_validate_email_domain_check_should_be_case_insensitive() {
if ( ! is_multisite() ) {
$this->markTestSkipped( __METHOD__ . ' requires multisite.' );
}

update_site_option( 'limited_email_domains', array( 'foo.com' ) );

$valid = invite_anyone_validate_email( 'Bar@FOO.COM' );

$this->assertSame( 'okay', $valid );
}
}

0 comments on commit 00f9e63

Please sign in to comment.