in reply to Prevent SQL Injection
In general you should store whatever data you receive in its original form, and not encoded for a particular output. For example, what if you need to send that text in a plain text email instead of an HTML email? What if you want to dump a bunch of rows of text into CSV?
Then when you need to use that text in a particular context, you can encode it appropriately. When you're sending it to the database, you should use placeholders, or if you must, use the quote method in DBI. When you're outputting it as HTML, then HTML-encode it. When you're passing it to a system call, apply shell escapes to it (is there a standard method for that?). If you're using it in a regex, use quotemeta or the \Q escape. And so on.
Update: andreas1234567's reply below is of course also correct.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Prevent SQL Injection
by andreas1234567 (Vicar) on Apr 08, 2008 at 07:57 UTC | |
Re^2: Prevent SQL Injection
by davidj01 (Novice) on Apr 10, 2008 at 16:14 UTC |