From 150d48d5f28f04bda8364ecbe092c5bb27ee4808 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 8 Oct 2010 11:19:10 +0000 Subject: Fixes #2161 - using filter_var() in email validation and moved is_email_address() to the input library git-svn-id: http://code.elgg.org/elgg/trunk@7036 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/input.php | 10 ++++++++++ engine/lib/users.php | 20 -------------------- 2 files changed, 10 insertions(+), 20 deletions(-) (limited to 'engine') diff --git a/engine/lib/input.php b/engine/lib/input.php index 17a330851..324b0cec4 100644 --- a/engine/lib/input.php +++ b/engine/lib/input.php @@ -106,6 +106,16 @@ function sanitise_filepath($path, $append_slash = TRUE) { return $path; } +/** + * Validates an email address. + * + * @param string $address Email address. + * @return bool + */ +function is_email_address($address) { + return filter_var($address, FILTER_VALIDATE_EMAIL) === $address; +} + /** * Page handler for autocomplete endpoint. * diff --git a/engine/lib/users.php b/engine/lib/users.php index 05311ab9d..c9add2541 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -874,26 +874,6 @@ function elgg_user_resetpassword_page_handler($page) { page_draw($title, elgg_view_layout('one_column', $content)); } -/** - * Validates an email address. - * - * @param string $address Email address. - * @return bool - */ -function is_email_address($address) { - // @todo Make this better! - - if (strpos($address, '@')=== false) { - return false; - } - - if (strpos($address, '.')=== false) { - return false; - } - - return true; -} - /** * Simple function that will generate a random clear text password suitable for feeding into generate_user_password(). * -- cgit v1.2.3