Make WordPress Core

Opened 20 years ago

Closed 20 years ago

Last modified 19 years ago

#2729 closed defect (bug) (fixed)

Regular expression bug in sanitize_user

Reported by: grigs's profile grigs Owned by: markjaquith's profile markjaquith
Milestone: Priority: normal
Severity: normal Version: 2.0.2
Component: General Keywords: has-patch commit
Focuses: Cc:

Description

I think I may have found a bug in the sanitize_user function in
functions-formatting.php. Currently, lines 275 - 277 read:

If strict, reduce to ASCII for max portability.
if ( $strict )

$username = preg_replace('|[a-z0-9 _.-@]|i', , $username);

It appears that what this is trying to do is allow hyphens (along
with many other characters). However, the regex does not match the
hyphens. I believe the reg ex needs a back slash like this:

$username = preg_replace('|[a-z0-9 _.\-@]|i', , $username);

I checked on the hackers mailing list and received confirmation that this appears to be a bug before submitting it here.

NOTE: The wiki formatting is stripping some of the information from the regular expressions above. I looked at the formatting guide, and didn't see a good way to escape it correctly. The gist of the ticket is that a backslash needs to be put before the hyphen. Please check the original source code to get a clean version of the regex.

Attachments (1)

regex_escape_dash.diff (529 bytes) - added by markjaquith 20 years ago.
patch to fix the regex

Download all attachments as: .zip

Change History (6)

@markjaquith
20 years ago

patch to fix the regex

#1 @markjaquith
20 years ago

  • Keywords has-patch commit added
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

Uploaded patch adds escaping slash to the regex.

#2 @ryan
20 years ago

  • Milestone set to 2.0.3

#3 @ryan
20 years ago

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

(In [3794]) sanitize_user regex fix from grigs. fixes #2729

#4 @ryan
20 years ago

  • Resolution set to fixed

(In [3795]) sanitize_user regex fix from grigs. fixes #2729

#5 @(none)
19 years ago

  • Milestone 2.0.3 deleted

Milestone 2.0.3 deleted

Note: See TracTickets for help on using tickets.