Skip to content

Commit

Permalink
[#33948] fix email validation, allowing email with new domain name
Browse files Browse the repository at this point in the history
extension. (Fixes #4135)
  • Loading branch information
rvbgnu authored and infograf768 committed Dec 6, 2014
1 parent 353a396 commit b89a595
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion libraries/joomla/form/rules/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class JFormRuleEmail extends JFormRule
* @var string
* @since 11.1
*/
protected $regex = '^[\w.-]+(\+[\w.-]+)*@\w+[\w.-]*?\.\w{2,4}$';
protected $regex = '^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$';


/**
* Method to test the email address and optionally check for uniqueness.
Expand Down
11 changes: 6 additions & 5 deletions libraries/joomla/mail/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ public static function isEmailAddress($email)

/*
* Check the local address
* We're a bit more conservative about what constitutes a "legal" address, that is, A-Za-z0-9!#$%&\'*+/=?^_`{|}~-
* Also, the last character in local cannot be a period ('.')
* We're a bit more conservative about what constitutes a "legal" address, that is, a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-
* The first and last character in local cannot be a period ('.')
* Also, period should not appear 2 or more times consecutively
*/
$allowed = 'A-Za-z0-9!#&*+=?_-';
$allowed = 'a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-';
$regex = "/^[$allowed][\.$allowed]{0,63}$/";
if (!preg_match($regex, $local) || substr($local, -1) == '.')
if (!preg_match($regex, $local) || substr($local, -1) == '.' || $local[0] == '.' || preg_match('/\.\./', $local))
{
return false;
}
Expand All @@ -147,7 +148,7 @@ public static function isEmailAddress($email)

// Check the domain
$domain_array = explode(".", rtrim($domain, '.'));
$regex = '/^[A-Za-z0-9-]{0,63}$/';
$regex = '/^[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/';
foreach ($domain_array as $domain)
{

Expand Down
2 changes: 1 addition & 1 deletion media/system/js/validate-uncompressed.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var JFormValidator = new Class({

this.setHandler('email',
function (value) {
regex=/^[a-zA-Z0-9._-]+(\+[a-zA-Z0-9._-]+)*@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
regex=/^[a-zA-Z0-9.!#$%&’*+\/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
return regex.test(value);
}
);
Expand Down
2 changes: 1 addition & 1 deletion media/system/js/validate.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b89a595

Please sign in to comment.