]> git.mxchange.org Git - friendica.git/commitdiff
Update and Remove isValidEmail
authorAdam Magness <adam.magness@gmail.com>
Fri, 9 Nov 2018 18:18:42 +0000 (13:18 -0500)
committerAdam Magness <adam.magness@gmail.com>
Fri, 9 Nov 2018 18:18:42 +0000 (13:18 -0500)
change function calls, and remove unneeded function.

mod/dirfind.php
mod/invite.php
mod/settings.php
src/Model/User.php
src/Util/Strings.php

index b814d3b4f743ef0e685a5506c138fe13e5c4e8d8..7ef217253e8dbd1663f335d3aab19c82724a628a 100644 (file)
@@ -53,7 +53,7 @@ function dirfind_content(App $a, $prefix = "") {
        if (strpos($search,'@') === 0) {
                $search = substr($search,1);
                $header = L10n::t('People Search - %s', $search);
-               if ((Strings::isValidEmail($search) && Network::isEmailDomainValid($search)) ||
+               if ((filter_var($search, FILTER_VALIDATE_EMAIL) && Network::isEmailDomainValid($search)) ||
                        (substr(Strings::normaliseLink($search), 0, 7) == "http://")) {
                        $user_data = Probe::uri($search);
                        $discover_user = (in_array($user_data["network"], [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::OSTATUS, Protocol::DIASPORA]));
index 5d33dd30aa6afb5a109dfe6bc3f6ff2f3922bfb0..e0c73aa344266fdd5f106d80583226ead621821f 100644 (file)
@@ -56,7 +56,7 @@ function invite_post(App $a)
        foreach ($recipients as $recipient) {
                $recipient = trim($recipient);
 
-               if (! Strings::isValidEmail($recipient)) {
+               if (!filter_var($recipient, FILTER_VALIDATE_EMAIL)) {
                        notice(L10n::t('%s : Not a valid email address.', $recipient) . EOL);
                        continue;
                }
index 142555691fc6f2c0ac309ae92114c78a32a41ae5..e9dd023f9d04b35afa333b46ed5d84ab58ea29d1 100644 (file)
@@ -517,7 +517,7 @@ function settings_post(App $a)
                        $email = $a->user['email'];
                }
                //  check the email is valid
-               if (!Strings::isValidEmail($email)) {
+               if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
                        $err .= L10n::t('Invalid email.');
                }
                //  ensure new email is not the admin mail
index 7447c02740434121dcc1330577185f7bcb85901a..e03bf1c395f57d46178ce97452795ccc7cace80b 100644 (file)
@@ -499,7 +499,7 @@ class User
                        throw new Exception(L10n::t('Your email domain is not among those allowed on this site.'));
                }
 
-               if (!Strings::isValidEmail($email) || !Network::isEmailDomainValid($email)) {
+               if (!filter_var($email, FILTER_VALIDATE_EMAIL) || !Network::isEmailDomainValid($email)) {
                        throw new Exception(L10n::t('Not a valid email address.'));
                }
                if (self::isNicknameBlocked($nickname)) {
index 5636a5ca024a65906dd5ea187cf33abf99672ce9..30f8b7329a0c25400338549920287852d29e2722 100644 (file)
@@ -353,18 +353,6 @@ class Strings
         return $ret;
     }
 
-    /**
-     * @brief Check for a valid email string
-     *
-     * @param string $email_address Email address to be evaluated.
-     * 
-     * @return boolean  Value indicating whether or not the string is a valid email address.
-     */
-    public static function isValidEmail($email_address)
-    {
-        return preg_match('/^[_a-zA-Z0-9\-\+]+(\.[_a-zA-Z0-9\-\+]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+$/', $email_address);
-    }
-
     /**
      * @brief Normalize url
      *