<!--- in Application.cfm --->

<cfscript>

function isValid( strInput ){

            // NOTE: the hash character must be escaped

            // to prevent the CF engine thinking it's the start

            // of a variable name

            var reRegEx = "/(\%27)|(\')|(\-\-)|(\%23)|(##)/ix";

            if( REFindNoCase( reRegEx, arguments.strInput ) GT 0 ){

                        return false;

            } else {

                        return true;

}

}

</cfscript>

...

<!--- in your processing code --->

<cfif isValid( form.whatever )>

            <!--- ....do stuff --->

<cfelse>

            <!--- ....don't do stuff --->

</cfif>



Hope that helps

Alistair

Alistair Davidson

Senior Technical Developer

Headshift.com

------------------------------------------
HEADSHIFT >>  www.headshift.com <blocked::http://www.headshift.com/>
T: 020 7357 7358  

------------------------------------------
smarter  >  simpler  >  social  >

  _____  

From: Ian Vaughan [mailto:[EMAIL PROTECTED]
Sent: 25 June 2004 09:58
To: CF-Talk
Subject: Coldfusion & Regex

Can anybody on the list provide any examples of using coldfusion with
regex.

For example I have the following line of regex that checks for the
detection of SQL meta characters, which will help prevent SQL Injection
etc

/(\%27)|(\')|(\-\-)|(\%23)|(#)/ix

I envisage this will be placed in the application .cfm of the site, but
how would you integrate it in with coldfusion to check for invalid input
via cookies, form input, http entries etc???

Any ideas would be most welcome

Thanks

Ian

  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to