Skip to content

Commit

Permalink
Update to 1.9.9
Browse files Browse the repository at this point in the history
- Fix validate email addresses in Register [#143]
  • Loading branch information
Jako committed Sep 18, 2020
1 parent f0fb7c1 commit 2a7e119
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 39 deletions.
2 changes: 1 addition & 1 deletion _build/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"lowCaseName": "login",
"description": "Login and Registrations",
"author": "Jason Coward & Shaun McCormick",
"version": "1.9.8-pl2",
"version": "1.9.9",
"package": {
"elements": {
"snippets": [
Expand Down
Binary file added _packages/login-1.9.9-pl.transport.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions core/components/login/docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog for Login
===================

Login 1.9.9
------------------------------------
- Fix validate email addresses in Register [#143]

Login 1.9.8
------------------------------------
- Allow persistParams when redirectUnsetDefaultParams is true [#157]
Expand Down
51 changes: 13 additions & 38 deletions core/components/login/model/login/loginvalidator.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,52 +394,27 @@ public function password_confirm($key,$value,$param = 'password_confirm') {
*/
public function email($key,$value) {
/* allow empty emails, :required should be used to prevent blank field */
if (empty($value)) return true;
if (empty($value)) {
return true;
}

/* validate length and @ */
$pattern = "^[^@]{1,64}\@[^\@]{1,255}$";
$condition = $this->config['use_multibyte'] ? @mb_ereg($pattern, $value) : @preg_match('#' . preg_quote($pattern, '#') . '#', $value);
if (!$condition) {
return $this->_getErrorMessage($key,'vTextEmailInvalid','register.email_invalid',array(
/* validate email with filter_var */
if ((filter_var($value, FILTER_VALIDATE_EMAIL) === false) || (strlen($value) > 99)) {
return $this->_getErrorMessage($key, 'vTextEmailInvalid', 'register.email_invalid', array(
'field' => $key,
'value' => $value,
));
}

/* validate domain with filter_var */
$email_array = explode("@", $value);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
$pattern = "^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$";
$condition = $this->config['use_multibyte'] ? @mb_ereg($pattern, $local_array[$i]) : @preg_match('#' . preg_quote($pattern, '#') . '#', $local_array[$i]);
if (!$condition) {
return $this->_getErrorMessage($key,'vTextEmailInvalid','register.email_invalid',array(
'field' => $key,
'value' => $value,
));
}
}
/* validate domain */
$pattern = "^\[?[0-9\.]+\]?$";
$condition = $this->config['use_multibyte'] ? @mb_ereg($pattern, $email_array[1]) : @preg_match('#' . preg_quote($pattern, '#') . '#', $email_array[1]);
if (!$condition) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return $this->_getErrorMessage($key,'vTextEmailInvalidDomain','register.email_invalid_domain',array(
'field' => $key,
'value' => $value,
));
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
$pattern = "^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$";
$condition = $this->config['use_multibyte'] ? @mb_ereg($pattern, $domain_array[$i]) : @preg_match('#' . preg_quote($pattern, '#') . '#', $domain_array[$i]);
if (!$condition) {
return $this->_getErrorMessage($key,'vTextEmailInvalidDomain','register.email_invalid_domain',array(
'field' => $key,
'value' => $value,
));
}
}
if (!isset($email_array[1]) || (filter_var($email_array[1], FILTER_VALIDATE_DOMAIN) === false)) {
return $this->_getErrorMessage($key, 'vTextEmailInvalidDomain', 'register.email_invalid_domain', array(
'field' => $key,
'value' => $value,
));
}

return true;
}

Expand Down

0 comments on commit 2a7e119

Please sign in to comment.