in reply to Prevent SQL Injection
use DBI; my $dbh = DBI->connect(...); # WRONG my $insert = $dbh->prepare("INSERT INTO my_table VALUES(my_col +umn)"); # Thanks Narveson! my $insert = $dbh->prepare("INSERT INTO my_table (my_column) VALUES( ? + )"); my $evil_string = q{"'|?°*;--}; $insert->execute($evil_string); # no problem
HTML escaping isn't the universal solution because different output formats use different quoting mechanisms, and your example system call wouldn't know that ' is a single quote.
So for all other applications you have to escape individually, so storing quoted strings in the DB isn't really helpful.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Prevent SQL Injection
by Narveson (Chaplain) on Apr 07, 2008 at 15:20 UTC | |
|
Re^2: Prevent SQL Injection
by davidj01 (Novice) on Apr 07, 2008 at 15:34 UTC | |
by moritz (Cardinal) on Apr 07, 2008 at 15:50 UTC | |
by apl (Monsignor) on Apr 07, 2008 at 16:15 UTC | |
by davidj01 (Novice) on Apr 07, 2008 at 16:58 UTC |