Make WordPress Core

Changeset 35629


Ignore:
Timestamp:
11/12/2015 04:29:45 PM (11 years ago)
Author:
SergeyBiryukov
Message:

Users: After [35189], make 'illegal_user_logins' check case-insensitive.

Props juliobox.
Fixes #27317.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/user.php

    r35190 r35629  
    144144
    145145        /** This filter is documented in wp-includes/user-functions.php */
    146         if ( in_array( $user->user_login, apply_filters( 'illegal_user_logins', array() ) ) ) {
     146        $illegal_logins = apply_filters( 'illegal_user_logins', array() );
     147
     148        if ( in_array( strtolower( $user->user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
    147149                $errors->add( 'illegal_user_login', __( '<strong>ERROR</strong>: Sorry, that username is not allowed.' ) );
    148150        }
  • trunk/src/wp-includes/ms-functions.php

    r35325 r35629  
    433433
    434434        /** This filter is documented in wp-includes/user-functions.php */
    435         if ( in_array( $user_name, apply_filters( 'illegal_user_logins', array() ) ) ) {
     435        $illegal_logins = apply_filters( 'illegal_user_logins', array() );
     436
     437        if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ) ) ) {
    436438                $errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
    437439        }
  • trunk/src/wp-includes/user-functions.php

    r35618 r35629  
    13291329         * @param array $usernames Array of blacklisted usernames.
    13301330         */
    1331         if ( in_array( $user_login, apply_filters( 'illegal_user_logins', array() ) ) ) {
     1331        $illegal_logins = apply_filters( 'illegal_user_logins', array() );
     1332
     1333        if ( in_array( strtolower( $user_login ), array_map( 'strtolower', $illegal_logins ) ) ) {
    13321334                return new WP_Error( 'illegal_user_login', __( 'Sorry, that username is not allowed.' ) );
    13331335        }
  • trunk/tests/phpunit/tests/user.php

    r35618 r35629  
    596596        /**
    597597         * @ticket 27317
    598          */
    599         function test_illegal_user_logins_single() {
     598         * @dataProvider _illegal_user_logins_data
     599         */
     600        function test_illegal_user_logins_single( $user_login ) {
    600601                $user_data = array(
    601                         'user_login' => 'testuser',
     602                        'user_login' => $user_login,
    602603                        'user_email' => 'testuser@example.com',
    603604                        'user_pass'  => wp_generate_password(),
    … …  
    619620        /**
    620621         * @ticket 27317
    621          */
    622         function test_illegal_user_logins_multisite() {
     622         * @dataProvider _illegal_user_logins_data
     623         */
     624        function test_illegal_user_logins_multisite( $user_login ) {
    623625                if ( ! is_multisite() ) {
    624626                        return;
    … …  
    626628
    627629                $user_data = array(
    628                         'user_login' => 'testuser',
     630                        'user_login' => $user_login,
    629631                        'user_email' => 'testuser@example.com',
    630632                );
    … …  
    641643                $this->assertInstanceOf( 'WP_Error', $response['errors'] );
    642644                $this->assertEquals( 0, count( $response['errors']->get_error_codes() ) );
     645        }
     646
     647        function _illegal_user_logins_data() {
     648                return array(
     649                        array( 'testuser' ),
     650                        array( 'TestUser' ),
     651                );
    643652        }
    644653
Note: See TracChangeset for help on using the changeset viewer.