Commit aefeff9d authored by preed%sigkill.com's avatar preed%sigkill.com

Bug 165221: Apostrophes not properly handled during account creation. r=joel,r2=bbaetz

parent 4c1922a6
...@@ -65,7 +65,6 @@ if (defined($login)) { ...@@ -65,7 +65,6 @@ if (defined($login)) {
# We've been asked to create an account. # We've been asked to create an account.
my $realname = trim($::FORM{'realname'}); my $realname = trim($::FORM{'realname'});
CheckEmailSyntax($login); CheckEmailSyntax($login);
trick_taint($login);
$vars->{'login'} = $login; $vars->{'login'} = $login;
if (!ValidateNewUser($login)) { if (!ValidateNewUser($login)) {
......
...@@ -552,11 +552,19 @@ sub ValidateNewUser { ...@@ -552,11 +552,19 @@ sub ValidateNewUser {
return 0; return 0;
} }
my $sqluname = SqlQuote($username);
# Reject if the new login is part of an email change which is # Reject if the new login is part of an email change which is
# still in progress # still in progress
#
# substring/locate stuff: bug 165221; this used to use regexes, but that
# was unsafe and required weird escaping; using substring to pull out
# the new/old email addresses and locate() to find the delimeter (':')
# is cleaner/safer
SendSQL("SELECT eventdata FROM tokens WHERE tokentype = 'emailold' SendSQL("SELECT eventdata FROM tokens WHERE tokentype = 'emailold'
AND eventdata like '%:$username' AND SUBSTRING(eventdata, 1, (LOCATE(':', eventdata) - 1)) = $sqluname
OR eventdata like '$username:%'"); OR SUBSTRING(eventdata, (LOCATE(':', eventdata) + 1)) = $sqluname");
if (my ($eventdata) = FetchSQLData()) { if (my ($eventdata) = FetchSQLData()) {
# Allow thru owner of token # Allow thru owner of token
if($old_username && ($eventdata eq "$old_username:$username")) { if($old_username && ($eventdata eq "$old_username:$username")) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment