Ticket #2729 (closed defect: fixed)

Opened 3 years ago

Last modified 2 years ago

Regular expression bug in sanitize_user

Reported by: grigs Assigned to: markjaquith
Priority: normal Milestone:
Component: General Version: 2.0.2
Severity: normal Keywords: has-patch commit
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

regex_escape_dash.diff (0.5 kB) - added by markjaquith on 05/18/06 01:17:08.
patch to fix the regex

Change History

05/18/06 01:17:08 changed by markjaquith

  • attachment regex_escape_dash.diff added.

patch to fix the regex

05/18/06 01:18:09 changed by markjaquith

  • keywords set to has-patch commit.
  • owner changed from anonymous to markjaquith.
  • status changed from new to assigned.

Uploaded patch adds escaping slash to the regex.

05/19/06 06:33:14 changed by ryan

  • milestone set to 2.0.3.

05/26/06 17:27:36 changed by ryan

  • status changed from assigned to closed.
  • resolution set to fixed.

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

05/26/06 17:27:54 changed by ryan

  • status changed from closed to closed.
  • resolution set to fixed.

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

11/30/06 19:41:50 changed by

  • milestone deleted.

Milestone 2.0.3 deleted