WordPress.org

Make WordPress Core

Ticket #33336: 33336.2.diff

File 33336.2.diff, 2.4 KB (added by DrewAPicture, 6 years ago)

Combined

  • src/wp-includes/ms-functions.php

     
    412412        $orig_username = $user_name;
    413413        $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
    414414
    415         if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) {
    416                 $errors->add( 'user_name', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) );
     415        if ( $user_name != $orig_username
     416                || preg_match( '/[^a-z0-9]/', $user_name )
     417                || false !== strpos( $user_name, '_' )
     418        ) {
     419                $errors->add( 'user_name', __( 'Usernames can only contain lowercase letters (a-z) and numbers.' ) );
    417420                $user_name = $orig_username;
    418421        }
    419422
     
    440443                $errors->add( 'user_name', __( 'Username may not be longer than 60 characters.' ) );
    441444        }
    442445
    443         if ( strpos( $user_name, '_' ) !== false )
    444                 $errors->add( 'user_name', __( 'Sorry, usernames may not contain the character “_”!' ) );
    445 
    446446        // all numeric?
    447447        if ( preg_match( '/^[0-9]*$/', $user_name ) )
    448448                $errors->add('user_name', __('Sorry, usernames must have letters too!'));
     
    561561        if ( empty( $blogname ) )
    562562                $errors->add('blogname', __( 'Please enter a site name.' ) );
    563563
    564         if ( preg_match( '/[^a-z0-9]+/', $blogname ) )
    565                 $errors->add('blogname', __( 'Only lowercase letters (a-z) and numbers are allowed.' ) );
     564        if ( preg_match( '/[^a-z0-9]+/', $blogname ) || false !== strpos( $blogname, '_' ) ) {
     565                $errors->add( 'blogname', __( 'Site names can only contain lowercase letters (a-z) and numbers.' ) );
     566        }
    566567
    567568        if ( in_array( $blogname, $illegal_names ) )
    568569                $errors->add('blogname',  __( 'That name is not allowed.' ) );
     
    570571        if ( strlen( $blogname ) < 4 && !is_super_admin() )
    571572                $errors->add('blogname',  __( 'Site name must be at least 4 characters.' ) );
    572573
    573         if ( strpos( $blogname, '_' ) !== false )
    574                 $errors->add( 'blogname', __( 'Sorry, site names may not contain the character &#8220;_&#8221;!' ) );
    575 
    576574        // do not allow users to create a blog that conflicts with a page on the main blog.
    577575        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 ) ) )
    578576                $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );