oh god I'm having one of those fridays. I have a headache already thanks to
cfpop STILL wigging out on unknown encodings and now I have this little
conumdrum...

I'm trying to validate e-mail addresses before they're sent out so that
cfmail doesn't die a hideous and agonising death.

this is a quick test page I've knocked up to get the theory right, only its
not quite working.

<cfsavecontent variable="mails">[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]
rich&[EMAIL PROTECTED]
[EMAIL PROTECTED]>ango.com
[EMAIL PROTECTED] *
[EMAIL PROTECTED]>
[EMAIL PROTECTED]@malon.com</cfsavecontent>

<cfscript>
mails = replacenocase(mails, chr(10), "", "ALL");
mails = listchangedelims(mails, ",", chr(13));
regex = "[a-z0-9][-\._a-z0-9]*@([a-z0-9][-_a-z0-9]*\.)+[a-z]{2,6}";

for (i=1; i lte listlen(mails);i=i+1) {
        email = listgetat(mails, i);
        badmailvar = 0;
        reversedmail = reverse(trim(email));
        if (NOT refindnocase("[a-z0-9]", left(reversedmail,1))) {
                badmailvar = 1;
        } else if (NOT refindnocase("[a-z0-9]", left(email,1))) {
                badmailvar = 1;
        } else if (listlen(email, "@") GT 2) {
                badmailvar = 1;
        } else if (NOT refindnocase(regex, email)) {
                badmailvar = 1;
        }
        
        if (badmailvar) {
                writeoutput('#email# &lt;&lt;BAD<br>');
        } else {
                writeoutput('#email#<br>');
        }
}
</cfscript>

Now, it works fine, correctly marking the bad emails and not marking the one
good one (the top 1). But for some reason it insists that
rich&[EMAIL PROTECTED] is NOT a bad email, despite the [-\._a-z0-9]*
clearly stating that ampersands are not allowed. whaddafug? Its 11:17am and
I want to go home already.

Can someone please point out my no doubt obvious mishtak?

Rich.


-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to