diff options
author | Andreas Gohr <andi@splitbrain.org> | 2008-10-11 19:32:45 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2008-10-11 19:32:45 +0200 |
commit | e8f8d645be4a431ee7114859b9aedae042f52ead (patch) | |
tree | 9c503985f76b2d75a779854502e1cd6387ee0ec8 /inc/mail.php | |
parent | abe88ecbb1016580584d00091f6de364d509933f (diff) | |
download | rpg-e8f8d645be4a431ee7114859b9aedae042f52ead.tar.gz rpg-e8f8d645be4a431ee7114859b9aedae042f52ead.tar.bz2 |
use EmailAddressValidator class for email validation FS#1503
darcs-hash:20081011173245-7ad00-578e03ca701fc4443ba91329be6ac1ca9344c7a7.gz
Diffstat (limited to 'inc/mail.php')
-rw-r--r-- | inc/mail.php | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/inc/mail.php b/inc/mail.php index 4b27963ee..a7a878c2d 100644 --- a/inc/mail.php +++ b/inc/mail.php @@ -8,6 +8,7 @@ if(!defined('DOKU_INC')) define('DOKU_INC',fullpath(dirname(__FILE__).'/../').'/'); require_once(DOKU_INC.'inc/utf8.php'); + require_once(DOKU_INC.'inc/EmailAddressValidator.php'); // end of line for mail lines - RFC822 says CRLF but postfix (and other MTAs?) // think different @@ -174,26 +175,14 @@ function mail_encode_address($string,$header='',$names=true){ } /** - * Uses a regular expresion to check if a given mail address is valid - * - * May not be completly RFC conform! - * @link http://www.faqs.org/rfcs/rfc2822.html (paras 3.4.1 & 3.2.4) - * - * @author Chris Smith <chris@jalakai.co.uk> + * Check if a given mail address is valid * * @param string $email the address to check * @return bool true if address is valid */ - -// patterns for use in email detection and validation -// NOTE: there is an unquoted '/' in RFC2822_ATEXT, it must remain unquoted to be used in the parser -// the pattern uses non-capturing groups as captured groups aren't allowed in the parser -// select pattern delimiters with care! -if (!defined('RFC2822_ATEXT')) define('RFC2822_ATEXT',"0-9a-zA-Z!#$%&'*+/=?^_`{|}~-"); -if (!defined('PREG_PATTERN_VALID_EMAIL')) define('PREG_PATTERN_VALID_EMAIL', '['.RFC2822_ATEXT.']+(?:\.['.RFC2822_ATEXT.']+)*@(?i:[0-9a-z][0-9a-z-]*\.)+(?i:[a-z]{2,4}|museum|travel)'); - function mail_isvalid($email){ - return preg_match('<^'.PREG_PATTERN_VALID_EMAIL.'$>i', $email); + $validator = new EmailAddressValidator; + return $validator->check_email_address($email); } /** |