summaryrefslogtreecommitdiffstats
path: root/system/libraries/Email.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2017-11-09 19:38:33 +0100
committerAndrey Andreev <narf@devilix.net>2017-11-09 19:38:33 +0100
commit4fd2d49461cd871a99a63c51563b8aee3d023abd (patch)
tree9741f7f48680d6c18d0aa4dc45ab076c9a144ec2 /system/libraries/Email.php
parent37134fd545ba39804b3f9fb6f51547d422d1e261 (diff)
More on #5003
Diffstat (limited to 'system/libraries/Email.php')
-rw-r--r--system/libraries/Email.php18
1 files changed, 12 insertions, 6 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 3b1da8de0..948cdb5c2 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -1034,10 +1034,13 @@ class CI_Email {
*/
public function valid_email($email)
{
- if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
+ if (function_exists('idn_to_ascii') && strpos($email, '@'))
{
- $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003;
- $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, $variant);
+ list($account, $domain) = explode('@', $email, 2);
+ $domain = is_php('5.4')
+ ? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)
+ : idn_to_ascii($domain);
+ $email = $account.'@'.$domain;
}
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
@@ -1852,10 +1855,13 @@ class CI_Email {
*/
protected function _validate_email_for_shell(&$email)
{
- if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
+ if (function_exists('idn_to_ascii') && strpos($email, '@'))
{
- $variant = defined('INTL_IDNA_VARIANT_UTS46') ? INTL_IDNA_VARIANT_UTS46 : INTL_IDNA_VARIANT_2003;
- $email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos), 0, $variant);
+ list($account, $domain) = explode('@', $email, 2);
+ $domain = is_php('5.4')
+ ? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)
+ : idn_to_ascii($domain);
+ $email = $account.'@'.$domain;
}
return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email));