Skip to content

Commit

Permalink
Coding Standards: Use strict comparison in `wpmu_validate_blog_signup…
Browse files Browse the repository at this point in the history
…()`.

Follow-up to [https://mu.trac.wordpress.org/changeset/8 mu:8], [https://mu.trac.wordpress.org/changeset/543 mu:543],  [https://mu.trac.wordpress.org/changeset/550 mu:550], [https://mu.trac.wordpress.org/changeset/1364 mu:1364], [https://mu.trac.wordpress.org/changeset/1958 mu:1958], [12603], [32733].

Props debarghyabanerjee, aristath, poena, afercia, SergeyBiryukov.
See #62279, #62283.

git-svn-id: https://develop.svn.wordpress.org/trunk@59573 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
SergeyBiryukov committed Jan 3, 2025
1 parent 016bbec commit 8da02a8
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/wp-includes/ms-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,12 @@ function wpmu_validate_user_signup( $user_name, $user_email ) {
}

$illegal_names = get_site_option( 'illegal_names' );

if ( ! is_array( $illegal_names ) ) {
$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
add_site_option( 'illegal_names', $illegal_names );
}

if ( in_array( $user_name, $illegal_names, true ) ) {
$errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );
}
Expand Down Expand Up @@ -516,10 +518,12 @@ 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 ) ) {
$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 ) ) {
$email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );

if ( ! in_array( $email_domain, $limited_email_domains, true ) ) {
$errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) );
}
}
Expand Down Expand Up @@ -637,7 +641,8 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {

$errors = new WP_Error();
$illegal_names = get_site_option( 'illegal_names' );
if ( false == $illegal_names ) {

if ( ! is_array( $illegal_names ) ) {
$illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
add_site_option( 'illegal_names', $illegal_names );
}
Expand Down Expand Up @@ -721,7 +726,7 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) {
* unless it's the user's own username.
*/
if ( username_exists( $blogname ) ) {
if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login != $blogname ) ) ) {
if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login !== $blogname ) ) ) {
$errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
}
}
Expand Down

0 comments on commit 8da02a8

Please sign in to comment.