From 7cb8fc1b3b9610b83493dc6d2105db7dad118862 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Tue, 13 Oct 2015 17:32:17 +0000 Subject: [PATCH] Multisite: Improve two error strings specifying allowed characters in usernames and site names. Also removes two error strings that were likely never being triggered anyway due to the stricter character matching higher up. Props atomicjack, bjornjohansen, DrewAPicture. Fixes #33336. git-svn-id: https://develop.svn.wordpress.org/trunk@35142 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/ms-functions.php | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/wp-includes/ms-functions.php b/src/wp-includes/ms-functions.php index 2e67a3cfa3..968f1f9c91 100644 --- a/src/wp-includes/ms-functions.php +++ b/src/wp-includes/ms-functions.php @@ -413,7 +413,7 @@ function wpmu_validate_user_signup($user_name, $user_email) { $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) { - $errors->add( 'user_name', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) ); + $errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) ); $user_name = $orig_username; } @@ -440,9 +440,6 @@ function wpmu_validate_user_signup($user_name, $user_email) { $errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) ); } - if ( strpos( $user_name, '_' ) !== false ) - $errors->add( 'user_name', __( 'Sorry, usernames may not contain the character “_”!' ) ); - // all numeric? if ( preg_match( '/^[0-9]*$/', $user_name ) ) $errors->add('user_name', __('Sorry, usernames must have letters too!')); @@ -561,8 +558,9 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { if ( empty( $blogname ) ) $errors->add('blogname', __( 'Please enter a site name.' ) ); - if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) - $errors->add('blogname', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) ); + if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) { + $errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) ); + } if ( in_array( $blogname, $illegal_names ) ) $errors->add('blogname', __( 'That name is not allowed.' ) ); @@ -570,9 +568,6 @@ function wpmu_validate_blog_signup( $blogname, $blog_title, $user = '' ) { if ( strlen( $blogname ) < 4 && !is_super_admin() ) $errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); - if ( strpos( $blogname, '_' ) !== false ) - $errors->add( 'blogname', __( 'Sorry, site names may not contain the character “_”!' ) ); - // do not allow users to create a blog that conflicts with a page on the main blog. if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );