Commit ca07b6eb authored by mkanat%kerio.com's avatar mkanat%kerio.com

Bug 292718: LOCATE is not ANSI SQL (prevents user account creation)

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=joel, a=justdave
parent 3dabf17d
...@@ -1091,8 +1091,9 @@ sub insert_new_user ($$;$$) { ...@@ -1091,8 +1091,9 @@ sub insert_new_user ($$;$$) {
# Insert the new user record into the database. # Insert the new user record into the database.
$dbh->do("INSERT INTO profiles $dbh->do("INSERT INTO profiles
(login_name, realname, cryptpassword, disabledtext) (login_name, realname, cryptpassword, disabledtext,
VALUES (?, ?, ?, ?)", refreshed_when)
VALUES (?, ?, ?, ?, '1901-01-01 00:00:00')",
undef, undef,
($username, $realname, $cryptpassword, $disabledtext)); ($username, $realname, $cryptpassword, $disabledtext));
...@@ -1133,12 +1134,14 @@ sub is_available_username ($;$) { ...@@ -1133,12 +1134,14 @@ sub is_available_username ($;$) {
# #
# substring/locate stuff: bug 165221; this used to use regexes, but that # substring/locate stuff: bug 165221; this used to use regexes, but that
# was unsafe and required weird escaping; using substring to pull out # was unsafe and required weird escaping; using substring to pull out
# the new/old email addresses and locate() to find the delimeter (':') # the new/old email addresses and sql_position() to find the delimiter (':')
# is cleaner/safer # is cleaner/safer
my $sth = $dbh->prepare( my $sth = $dbh->prepare(
"SELECT eventdata FROM tokens WHERE tokentype = 'emailold' "SELECT eventdata FROM tokens WHERE tokentype = 'emailold'
AND SUBSTRING(eventdata, 1, (LOCATE(':', eventdata) - 1)) = ? AND SUBSTRING(eventdata, 1, ("
OR SUBSTRING(eventdata, (LOCATE(':', eventdata) + 1)) = ?"); . $dbh->sql_position(q{':'}, 'eventdata') . "- 1)) = ?
OR SUBSTRING(eventdata, ("
. $dbh->sql_position(q{':'}, 'eventdata') . "+ 1)) = ?");
$sth->execute($username, $username); $sth->execute($username, $username);
if (my ($eventdata) = $sth->fetchrow_array()) { if (my ($eventdata) = $sth->fetchrow_array()) {
......
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