in reply to Re^6: Removing malicious HTML entities (now with more questions!)
in thread Removing malicious HTML entities (now with more questions!)
In the latter case, the value(s) of the parameter(s) would not go directly into the SQL string, but would only be tested to figure out what function call(s), if any, should be added (as literals) to the SQL. Example:
There are other ways to handle this that would suffice (e.g. careful regex matches on untrusted values in order to include things in the SQL statement), but as a rule, the application should have a limited inventory of function calls that it supports/allows.my @flds = ( qw/foo bar status/ ); my @vals = @param{@flds}; my $valstr = join( ",", ("?") x @flds ); if ( $param{timestamp} ) { push @flds, "timestamp"; $valstr .= ",NOW()"; } my $sql = "insert into mytable (" . join( ",", @flds ) . ") values ($v +alstr)"; my $sth = $dbh->prepare( $sql ); $sth->execute( @vals );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: Removing malicious HTML entities (now with more questions!)
by techcode (Hermit) on Sep 08, 2008 at 12:00 UTC |