From 0abc0dfca3c4e9e17da07edc864e009c13222174 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 29 Aug 2016 15:15:49 +0300 Subject: Fix #4787 --- system/libraries/Form_validation.php | 4 ++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 61f0298fd..c39b65d89 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1229,9 +1229,9 @@ class CI_Form_validation { */ public function valid_email($str) { - if (function_exists('idn_to_ascii') && $atpos = strpos($str, '@')) + if (function_exists('idn_to_ascii') && sscanf($str, '%[^@]@%s', $name, $domain) === 2) { - $str = substr($str, 0, ++$atpos).idn_to_ascii(substr($str, $atpos)); + $str = $name.'@'.idn_to_ascii($domain); } return (bool) filter_var($str, FILTER_VALIDATE_EMAIL); diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index aa9af21b6..5bdcda934 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -23,6 +23,7 @@ Bug fixes for 3.1.1 - Fixed a bug (#4762) - :doc:`Cache Library ` 'file' driver method ``get_metadata()`` checked TTL time against ``mtime`` instead of the cache item's creation time. - Fixed a bug where :doc:`File Uploading Library ` generated error messages on PHP 7.1. - Fixed a bug (#4780) - :doc:`compatibility function ` ``hex2bin()`` didn't reject inputs of type "resource". +- Fixed a bug (#4787) - :doc:`Form Validation Library ` method ``valid_email()`` triggered ``E_WARNING`` when input emails have empty domain names. Version 3.1.0 ============= -- cgit v1.2.3-24-g4f1b