diff options
author | Dries Buytaert <dries@buytaert.net> | 2003-03-28 10:55:27 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2003-03-28 10:55:27 +0000 |
commit | d1be768b28b17315c7785cbd1c7769bdf64665c7 (patch) | |
tree | 6eb77f2e24c205df37fa834ba3a1145f6df08c05 /includes/common.inc | |
parent | 8e9d557ac83179d0c97a1b518965946856f1eac2 (diff) | |
download | brdo-d1be768b28b17315c7785cbd1c7769bdf64665c7.tar.gz brdo-d1be768b28b17315c7785cbd1c7769bdf64665c7.tar.bz2 |
- Moved the logic of email validation from user_validate_mail to a new function
in common.inc. Modified patch from Gerhard.
Diffstat (limited to 'includes/common.inc')
-rw-r--r-- | includes/common.inc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc index d946e64ba..306433e60 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -256,6 +256,26 @@ function table($header, $rows) { } /** + * Verify the syntax of the given e-mail address. Empty e-mail addresses + * are allowed. See RFC 2822 for details. + * + * @param $mail a email address + */ +function validate_email_address($mail) { + $user = '[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\`\|\{\}~\']+'; + $domain = '(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]\.?)+'; + $ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}'; + $ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}'; + + if (preg_match("/^$user@($domain|(\[($ipv4|$ipv6)\]))$/", $mail)) { + return 1; + } + else { + return 0; + } +} + +/** * Format a single result entry of a search query: * * @param $item a single search result as returned by <module>_search of type |