Skip to content
Permalink
Browse files Browse the repository at this point in the history
fixed a protential source of SQL injection
  • Loading branch information
Chris Herberte committed Feb 17, 2008
1 parent be62cfc commit 126c141
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions email_registration.module
Expand Up @@ -13,8 +13,8 @@ function email_registration_user($op, &$edit, &$account, $category = NULL) {
// if username generated from email record already exists, append underscore and number eg:(chris_123)
if (db_result(db_query("SELECT count(*) FROM {users} WHERE uid <> %d AND LOWER(name) = LOWER('%s')", $account->uid, $namenew)) > 0) {
// find the next number available to append to the name
$sql = "SELECT SUBSTRING_INDEX(name,'_',-1) FROM {users} WHERE name REGEXP '^%s_[0-9]+$' ORDER BY CAST(SUBSTRING_INDEX(name,'_',-1) AS UNSIGNED) DESC LIMIT 1";
$nameidx = db_result(db_query($sql, $namenew));
$sql = "SELECT SUBSTRING_INDEX(name,'_',-1) FROM {users} WHERE name REGEXP '%s' ORDER BY CAST(SUBSTRING_INDEX(name,'_',-1) AS UNSIGNED) DESC LIMIT 1";
$nameidx = db_result(db_query($sql, '^'. $namenew .'_[0-9]+$'));
$namenew .= '_'. ($nameidx + 1);
}
// replace with generated username
Expand Down

0 comments on commit 126c141

Please sign in to comment.