[clug-talk] Scrubbing/Sanitazing routine

Nick Wiltshire nick at dyna-tech.ca
Thu Sep 29 14:46:17 PDT 2005


On Thursday 29 September 2005 3:37 pm, Cirez Communications, inc. wrote:
> Quick q:
>
> In trying to sanitaze user input (I know, I know, there is no easy way
> to do this), is there is rather fast/uncomplicated way to accomplish
> this?
>
> A quick and dirty way to do this in perl is to create a hash with the
> ilegal characters and its replacements (key/value), then create a sub
> that takes a dirty string as argument, look it up and return the
> sanitized version. This is all well and good; but trying to do the
> same in Java it's rather resource intensive.
>
> Is there a simple way to accomplish this, given a list of 25 or so
> character to scrubb? I don't want to delete the characters just return
> the ASCII code in HTML compatible format i.e ASCII (67) as C
> Using  java's: (Object).replace(dirty_string, sanitized_string); for
> every possible character takes way to much time and resources...
> --

Is it too slow to create 2 arrays, arr_dirty and arr_replace, then loop 
through?



More information about the clug-talk mailing list