WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 4 years ago

Last modified 4 years ago

#24618 closed defect (bug) (fixed)

Enhancement for validate_username

Reported by: gwinh.lopez Owned by: chriscct7
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch commit
Focuses: Cc:

Description

the validate_username returns true on an empty string which obviously is not a valid username.

Attachments (4)

enhance.vun.diff (466 bytes) - added by gwinh.lopez 6 years ago.
24618.patch (472 bytes) - added by mordauk 6 years ago.
24618-tests.patch (780 bytes) - added by mordauk 6 years ago.
Unit tests for validate_username()
24618.2.patch (1.2 KB) - added by chriscct7 4 years ago.

Download all attachments as: .zip

Change History (13)

#1 @SergeyBiryukov
6 years ago

  • Component changed from Validation to Users
  • Keywords has-patch added; needs-patch removed

#2 @mordauk
6 years ago

I've just confirmed the bug.

@mordauk
6 years ago

#3 @mordauk
6 years ago

  • Keywords good-first-bug added

24618.patch is a refreshed patch with proper formatting.

I'm going to write up another patch shortly that adds unit tests for this as well.

#4 @mordauk
6 years ago

  • Type changed from enhancement to defect (bug)

@mordauk
6 years ago

Unit tests for validate_username()

#5 @mordauk
6 years ago

  • Keywords good-first-bug removed

24618-tests.patch adds some basic unit tests for validate_username(). I'm sure there are more assertions we could make, but this is better than none at all.

@chriscct7
4 years ago

#6 @chriscct7
4 years ago

  • Keywords commit added
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to chriscct7
  • Status changed from new to assigned

Refreshed the function changes, and then combined the unit tests and changes into a single patch

#7 @DrewAPicture
4 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 34856:

Users: Empty sanitized usernames should be considered invalid when passed through validate_username().

Adds tests.

Props gwinhlopez for the initial patch.
Props mordauk, chriscct7.
Fixes #24618.

#8 @DrewAPicture
4 years ago

In 34858:

Users: Add a separate test for checking the validity of a username containing uppercase characters in the scope of single vs multisite.

'JohnDoe' in single site: valid
'JohnDoe' in multisite: invalid

See #24618.

#9 @DrewAPicture
4 years ago

In 34859:

Users: Don't typo assertTrue() in a the uppercase letters validate_username() test.

See #24618.

Note: See TracTickets for help on using tickets.