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
This commit is contained in:
Drew Jaynes 2015-10-13 17:32:17 +00:00
parent 16b02b6768
commit 7cb8fc1b3b
1 changed files with 4 additions and 9 deletions

View File

@ -413,7 +413,7 @@ function wpmu_validate_user_signup($user_name, $user_email) {
$user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) ); $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) { 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; $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.' ) ); $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? // all numeric?
if ( preg_match( '/^[0-9]*$/', $user_name ) ) if ( preg_match( '/^[0-9]*$/', $user_name ) )
$errors->add('user_name', __('Sorry, usernames must have letters too!')); $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 ) ) if ( empty( $blogname ) )
$errors->add('blogname', __( 'Please enter a site name.' ) ); $errors->add('blogname', __( 'Please enter a site name.' ) );
if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
$errors->add('blogname', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) ); $errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
}
if ( in_array( $blogname, $illegal_names ) ) if ( in_array( $blogname, $illegal_names ) )
$errors->add('blogname', __( 'That name is not allowed.' ) ); $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() ) if ( strlen( $blogname ) < 4 && !is_super_admin() )
$errors->add('blogname', __( 'Site name must be at least 4 characters.' ) ); $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 &#8220;_&#8221;!' ) );
// do not allow users to create a blog that conflicts with a page on the main blog. // 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 ) ) ) 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.' ) ); $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );