From 43380703cb11cc68517c7c5b3b53da14eb8bb211 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 3 Jan 2025 22:57:22 +0000 Subject: [PATCH] Coding Standards: Use strict comparison in `wpmu_validate_blog_signup()`. 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. Built from https://develop.svn.wordpress.org/trunk@59573 git-svn-id: http://core.svn.wordpress.org/trunk@58959 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/ms-functions.php | 13 +++++++++---- wp-includes/version.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index e0ae1a0315..5bb3cab118 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -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.' ) ); } @@ -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!' ) ); } } @@ -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 ); } @@ -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!' ) ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index b3ed9221a2..10f61e6942 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59572'; +$wp_version = '6.8-alpha-59573'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.