shiphen wrote:
> Hi theSpaceGirl (miranda)
>
> Are you recommending that we all to ALL this pre-processing on ALL
> fields of ALL forms, then?!
Yep, without a doubt. If you dont, it's just asking for trouble --
especially when it's really simple to do.
>
> Out of interest have you actually come across people submitting
> SQL commands ?!
>
Yep
> And if so doesnt this lead to rather clumbsy slow data-capture forms?
> ...or do you still think it is it worth it in any case?
It's not as complicated as it sounds - you can write a single function
that is run to clean-up each form field before you deal with it. The
function only needs to written once, and then you can run that function
against each field.
Okay here's a chunk of ASP psuedo-code that would handle the form
fields:
' CODE
function processFields(userInput)
userInput=replace(userInput,"<", "")
userInput=replace(userInput,"'", "")
userInput=replace(userInput,"""", "")
userInput=replace(userInput,chr(13), "")
userInput=replace(userInput,chr(10), "")
userInput=replace(userInput,"swearword", "")
'... add as many replacements as you like
processFields = userInput
end function
' END CODE
So, then we can just process each field:
'CODE
username=processFields(request("username_field_from_form"))
password=processFields(request("password_field_from_form"))
city=processFields(request("city_field_from_form"))
'END CODE
So, it's really simple to process hundreds of fields instantly "pre"
validating them, stripping any hacks or bad data. This is of course all
possible in any language you true, and all runs at the server not the
client so CANNOT be bypassed by a user (or hacker!).
Hope that helps!
>> Stay informed about: Apple/Safari user inserting unwanted Carriage Returns (int..