I take the input line from the user and use it as parameters for the command line command line.
What is the best way to ensure that this input is "safe"? Aka they did not insert "; cd /; rm -rf" or some other ugliness in the field?
Without any disinfection, I have ...
@query = params[:query]
@result = %x( mycommand #{@query} )
I need to get the output of the command, so I can not use the system ("command", "parameters"), since this returns only true or false, but will provide protection.
I know this is dangerous ... thanks in advance.
source
share