Make WordPress Core

Ticket #24618: 24618.2.patch

File 24618.2.patch, 1.2 KB (added by chriscct7, 10 years ago)
  • src/wp-includes/user-functions.php

     
    11821182 */
    11831183function validate_username( $username ) {
    11841184        $sanitized = sanitize_user( $username, true );
    1185         $valid = ( $sanitized == $username );
     1185        $valid = ( $sanitized == $username && ! empty( $sanitized ) );
    11861186        /**
    11871187         * Filter whether the provided username is valid or not.
    11881188         *
  • tests/phpunit/tests/user.php

     
    596596                        if ( ! defined( 'WP_IMPORTING' ) ) {
    597597                                $this->assertWPError( $return );
    598598                        }
     599        }
     600
     601        /**
     602         * @ticket 24618
     603         */
     604        function test_validate_username() {
     605
     606                $this->assertTrue( validate_username( 'testusername' ) );
     607                $this->assertTrue( validate_username( 'JohnDoe' ) );
     608                $this->assertTrue( validate_username( 'test@test.com' ) );
     609                $this->assertFalse( validate_username( '' ) );
     610                $this->assertFalse( validate_username( '@#&99sd' ) );
     611
     612        }
    599613                }
    600614        }
    601615