SmartyValidate-2.6: validate_criteria.isEmail.php and RFC 2821

From: Date: Thu, 02 Feb 2006 18:18:52 +0000
Subject: SmartyValidate-2.6: validate_criteria.isEmail.php and RFC 2821
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-13293@lists.php.net to get a copy of this message
Hi there, I've been working on a form, which needs to validate if the input is a valid e-mail address and stumbled over this: When I enter an e-mail adress that contains umlauts, (e.g. äöüß don't know if you can read this...) the address is considered to be a valid e-mail address. However, I remembered that umlauts are not allowed and looked up RFC 2821, saying this: Systems MUST NOT define mailboxes in such a way as to require the use in SMTP of non-ASCII characters (octets with the high order bit set to one) or ASCII "control characters" (decimal value 0-31 and 127). These characters MUST NOT be used in MAIL or RCPT commands or other commands that require mailbox names. -- (http://ftp.rfc-editor.org/in-notes/rfc2821.txt, 4.1.2 Command Argument Syntax, Page 36) Looking at validate_criteria.isEmail.php I am under the impression - I am not the regexp-guru - that function smarty_validate_criteria_isEmail checks for conforming domain-parts, but not local-parts of e-mail adresses, right? Here's the function so you don't need to look it up: function smarty_validate_criteria_isEmail($value, $empty, &$params, &$formvars) { if(strlen($value) == 0) return $empty; // in case value is several addresses separated by newlines $_addresses = preg_split('![\n\r]+!', $value); foreach($_addresses as $_address) { $_is_valid = !(preg_match('!@.*@|\.\.|\,|\;!', $_address) || !preg_match('!^.+\@(\[?)[a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$!', $_address)); if(!$_is_valid) return false; } return true; } TIA, p@rick

« previous php.smarty.general (#13293) next »