[SMARTY] SmartyValidate-2.6: validate_criteria.isEmail.php and RFC 2821

Patrick Ben Koetter <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <[email protected]>
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

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.