diff options
author | Andrey Andreev <narf@devilix.net> | 2014-05-31 23:00:13 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-05-31 23:00:13 +0200 |
commit | 9549666a1d026a8d275ba707b6c56506999f01cc (patch) | |
tree | 7cd31155125b8dc1ac5ec7813d8382ce7e2a89e1 /system/libraries | |
parent | 6eb77da2db93af893955b320a768054e9519dc81 (diff) |
Add support for non-ASCII domain names in FV & Email classes' valid_email()
Depends on the Intl extension
Diffstat (limited to 'system/libraries')
-rw-r--r-- | system/libraries/Email.php | 5 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/system/libraries/Email.php b/system/libraries/Email.php index c39a26a15..88398d316 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1079,6 +1079,11 @@ class CI_Email { */ public function valid_email($email) { + if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) + { + $email = substr($email, 0, ++$atpos).idn_to_ascii(substr($email, $atpos)); + } + return (bool) filter_var($email, FILTER_VALIDATE_EMAIL); } diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index dc5d17fb3..555a65959 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1225,6 +1225,11 @@ class CI_Form_validation { */ public function valid_email($str) { + if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@')) + { + $email = substr($email, 0, ++$atpos).idn_to_ascii(substr($email, $atpos)); + } + return (bool) filter_var($str, FILTER_VALIDATE_EMAIL); } |