I have form with input fields, and I’m checking for bad input (evil scripts, etc) on the client side, but I also need to check on the server side. My @_params hash has nested data, arrays and objects:
{
"key_0" => {"nested_key_0" => ["array_val_0","array_val_1"], "nested_key_1" => {"nested_key_3" => "nested_value_0"} }
}
Do I have to write a recursive method to traverse the hash and look at each value? Is there a simple rails way to do this? Thanks!
It depends on what you’re doing exactly (presumably storing this data in the db and later displaying it?).
If you are saving this to the db, when you call Model.save it will sanitize the attributes. If you’re worried about scripts, you can display the data with the
hhelper:<%= h unsanitary_var %>