|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
RegEx causes Browser to 'hang' and CFHi,
Ive got a system where we allow a user to upload a CSV containing addressbook entries. I run a RegEx Email validation to check that the email of the record is in an appropriate format. Currently I have the following: <cfset sPattern = "([a-z0-9][-._a-z0-9]*)*[a-z0-9]+@{1,1}([a-z0-9][-_a-z0-9]*\.)+[a-z]{2,7}" /> return IIF(REFindNoCase(sFormatPattern, str) EQ 1, true, false); And similarly in the Javascript: var emailFilter = /([a-zA-Z0-9][-._a-zA-Z0-9]*)*[a-zA-Z0-9]+@{1,1}([a-zA-Z0-9][-_a-zA-Z0-9]*\.)+[a-zA-Z]{2,7}/g; return emailFilter.test(sEmail); Using an email address of: foobar.foobar.foobar.mediroute.snet.co.uk causes the browser (for the javascript) to 'hang' using all the CPU and causes CF to do similar (thus never rreturning the page to the user) Why is this happening, and how can I avoid potential problems like this in the future. Thanks in advance Jedi ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:21:878 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54 |
|
|
|
|
|
Re: RegEx causes Browser to 'hang' and CFFloading in the archives here, there's a reccommended regex for email.
I suspect that the way you've written yours is causing the engine to have to backtrack too many times. But that's just a guess. --Ben JediHomer wrote: > Hi, > > Ive got a system where we allow a user to upload a CSV containing > addressbook entries. I run a RegEx Email validation to check that the > email of the record is in an appropriate format. Currently I have the > following: > > <cfset sPattern = > "([a-z0-9][-._a-z0-9]*)*[a-z0-9]+@{1,1}([a-z0-9][-_a-z0-9]*\.)+[a-z]{2,7}" > /> > return IIF(REFindNoCase(sFormatPattern, str) EQ 1, true, false); > > > And similarly in the Javascript: > > var emailFilter = > /([a-zA-Z0-9][-._a-zA-Z0-9]*)*[a-zA-Z0-9]+@{1,1}([a-zA-Z0-9][-_a-zA-Z0-9]*\.)+[a-zA-Z]{2,7}/g; > return emailFilter.test(sEmail); > > > Using an email address of: > > foobar.foobar.foobar.mediroute.snet.co.uk > > causes the browser (for the javascript) to 'hang' using all the CPU > and causes CF to do similar (thus never rreturning the page to the > user) > > > Why is this happening, and how can I avoid potential problems like > this in the future. > > > Thanks in advance > > Jedi > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:21:880 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/21 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:21 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.21 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54 |
| Free embeddable forum powered by Nabble | Forum Help |