summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-06-27 14:34:18 +0200
committerAndrey Andreev <narf@bofh.bg>2012-06-27 14:34:18 +0200
commit6edf929449f50339c4cb52891426fa9d45e33e00 (patch)
tree963d70f006e24d34c62cebd27208e16c83a163a7
parentb66664b5decd68de50ae6c239c8d995d6c088d94 (diff)
parentd37f0e9cfe106ff1a15b8f09df27e4f3a004b907 (diff)
Merge pull request #1319 from timw4mail/email
Make valid_email helper function more accurate
-rw-r--r--system/helpers/email_helper.php4
-rw-r--r--system/libraries/Email.php4
-rw-r--r--system/libraries/Form_validation.php2
-rw-r--r--user_guide_src/source/changelog.rst1
4 files changed, 6 insertions, 5 deletions
diff --git a/system/helpers/email_helper.php b/system/helpers/email_helper.php
index 0516e938a..628667d4d 100644
--- a/system/helpers/email_helper.php
+++ b/system/helpers/email_helper.php
@@ -45,9 +45,9 @@ if ( ! function_exists('valid_email'))
* @param string
* @return bool
*/
- function valid_email($address)
+ function valid_email($email)
{
- return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address);
+ return filter_var($email, FILTER_VALIDATE_EMAIL);
}
}
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index dd5477e05..0fcdbd83e 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -706,9 +706,9 @@ class CI_Email {
* @param string
* @return bool
*/
- public function valid_email($address)
+ public function valid_email($email)
{
- return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $address);
+ return filter_var($email, FILTER_VALIDATE_EMAIL);
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 8e03e91f3..f3087f883 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -1076,7 +1076,7 @@ class CI_Form_validation {
*/
public function valid_email($str)
{
- return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $str);
+ return filter_var($str, FILTER_VALIDATE_EMAIL);
}
// --------------------------------------------------------------------
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index c0fa9d7f7..cc6220253 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -73,6 +73,7 @@ Release Date: Not Released
- ``read_file()`` is now a deprecated alias of ``file_get_contents()``.
- Added an optional parameter to :doc:`Date Helper <helpers/date_helper>` function ``timezone_menu()`` that allows more attributes to be added to the generated select tag.
- :doc:`Security Helper <helpers/security_helper>` function ``strip_image_tags()`` is now an alias for the same method in the :doc:`Security Library <libraries/security>`.
+ - Updated email validation methods to use filter_var so they are more accurate.
- Database