Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email address regular expression is wrong everywhere. #3718

Closed
jasminpatel opened this issue Dec 7, 2015 · 8 comments
Closed

Email address regular expression is wrong everywhere. #3718

jasminpatel opened this issue Dec 7, 2015 · 8 comments

Comments

@jasminpatel
Copy link

The email address validation in all opencart forms is wrong. There is sily mistake in regular expression given in statement.

    if ((utf8_strlen($this->request->post['email']) > 96) || !preg_match('/^[^\@]+@.*.[a-z]{2,15}$/i', $this->request->post['email'])) {
        $this->error['email'] = $this->language->get('error_email');
    }

If I add email address xyz@abc the email address will be validated. The pattern should match email address like xyz@abc.com for that the actual expression should be as below.

/^[^\@]+@.*.[a-z]{2,15}+.[a-z]{2,4}$/i

@ADDCreative
Copy link
Contributor

That expression doesn't look right to me. I think a \ just needs adding before the last . to match an actual . and not any character.

/^[^\@]+@.*\.[a-z]{2,15}$/i

The 15 for the length of the top level domain could possibly be made be bigger. The maximum they can be is 63 I believe, although there are none that long at the moment.

@prhost
Copy link

prhost commented Dec 7, 2015

I think the ideal would be to use the filter php, ex .: filter_var('xyz@abc.com', FILTER_VALIDATE_EMAIL)

@danielkerr
Copy link
Member

@prhost can not use filters as its an external php extension that is not instsalled on all hosts.

@falnyr
Copy link

falnyr commented Dec 11, 2015

@danielkerr Native since PHP 5.2, are you supporting lower versions? http://php.net/manual/en/function.filter-var.php

@chienhoang
Copy link
Contributor

Yeah, i think we should use filter_var since it's already a built-in function of PHP (I don't think there's any people still using PHP < 5.2

@danielkerr
Copy link
Member

im sure i added this before and got loads of complaints.

@danielkerr
Copy link
Member

i would be happy to use this as long as it is not a extension that some hosts dont install.

@danielkerr
Copy link
Member

ok if this is installed as part of php then it should put that email validation headache to bed once and for all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants