OT Email Well-Formed Checkers

Jim Ault JimAultWins at yahoo.com
Sun Nov 19 18:41:20 EST 2006

On 11/19/06 11:38 AM, "Sivakatirswami" <katir at hindu.org> wrote:

> OK, things are getting out of hand on some web UI's with garbage entry
> by bots, silly users or
> malcontents, who knows.. even the "enter twice" seems to be
> handled now by Artificial Hackers Anonymous.
> So I'm thinking we need to upgrade our small scripts we use to
> check on well formed email addresses.
> Of course the "ultimate" is to email them and wait for
> response, I want to avoid that layer for now.
> So: to everyone and anyone: can you post your well-formed email check
> functions that
>   you use in your CGI's  here? I have one, but it's like 8 years old.
> Ken, "Master of RegEx"  you must have something, n'est ce pas?

Nowadays I would start with the

"Re-Enter your email address, followed by a numeral, any numeral"
-- and you delete any numerals from the end of the emailString

put word 1 to -1 of line 1 of emailInput into emailStr1
put word 1 to -1 of line 1 of emailInput2 into emailStr2

set the itemDel to "@"
if the number of items in emailStr1 <> 2 then exit
--something is wrong

get (last char of emailStr1 is a number)
get it && (last char of emailStr2 is a number)
if "true" is not in it then exit

--do both strings in case someone gets confused
repeat until last char of emailStr1 is not a number
  delete last char of emailStr1
end repeat
repeat until last char of emailStr2 is not a number
  delete last char of emailStr2
end repeat
if emailStr1 is not emailStr2 then exit

--clean up for typos
replace comma with period in emailStr1
replace space with empty in emailStr1

if char -4 to -1 of emailStr1 is not among the words " .com .net .biz " then
--does not look likely

 checkForHaveAlreadyInDb emailStr1

Obviously  I am not in the business of web form security.  These are some of
the filters I would put in place if I did a high-volume, high-profile site
like yours.

Hope this helps give you ideas.

Jim Ault
Las Vegas

More information about the Use-livecode mailing list