Bug #1168

email_already_in_use() LOWER missing

Added by Diogo Parrinha almost 2 years ago. Updated over 1 year ago.

Status:Closed Start date:08/19/2010
Priority:Normal Due date:
Assignee:Ryan Gordon % Done:

100%

Category:Other
Target version:1.6.1
Reproducibility:Always Database Type:
Reported In MyBB Version:1.6.0 Database Version:
PHP Version: SQA assignments:
Browser:

Description

Hey,

Well I'm not sure if this is a bug or not but it seems it is since I can't find email being turned into lower cases before being inserted into the database. (I might have missed it though)

However, in this function:

/**
 * Checks to see if the email is already in use by another
 *
 * @param string The email to check.
 * @param string User ID of the user (updating only)
 * @return boolean True when in use, false when not.
 */
function email_already_in_use($email, $uid="")
{
    global $db;

    $uid_string = "";
    if($uid)
    {
        $uid_string = " AND uid != '".intval($uid)."'";
    }
    $query = $db->simple_select("users", "COUNT(email) as emails", "email = '".$db->escape_string(my_strtolower($email))."'{$uid_string}");

    if($db->fetch_field($query, "emails") > 0)
    {
        return true;
    }

    return false;
}

Souldn't email be LOWER ? I might be wrong but doesn't hurt pointing this out in case I'm not.

Associated revisions

Revision 5183
Added by Ryan Gordon over 1 year ago

Fixes email_already_in_use() LOWER missing (fixes:1168)

History

#1 Updated by Diogo Parrinha almost 2 years ago

Okay, I guess Redmine likes to parse:

LOWER(email)

to LOWER, so here it is.

I think it should be what I wrote above instead of just email. (in the query)

#2 Updated by Sebastian Wunderlich almost 2 years ago

According RFC 2822 and RFC 2821 local part of an email address is case sensitivity, so is not the same like
So I would not suggest to store email addresses in lower case in database.

#3 Updated by Diogo Parrinha almost 2 years ago

This is not the insert query, this a select query.
It converts the input email to lower cases but does not have LOWER around the email field to compare the lower cased email against the email in the database.

#4 Updated by Ryan Gordon over 1 year ago

  • Category set to Other
  • Status changed from New to Assigned
  • Assignee set to Ryan Gordon
  • Target version set to 1.6.1

#5 Updated by Ryan Gordon over 1 year ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

Applied in changeset r5183.

#6 Updated by Polar Bear over 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF