in reply to Security with a MEMO field
However, the real question is: what will you do with the memo? If all you'll ever do is put it in the DB (I doubt that), placeholders are enough. Otherwise, think ahead.$sth = $dbh->prepare("INSERT INTO dork (memo) VALUES (?)"); $sth->execute($unsafe_memo);
You should examine what you want to do with it in the future (e.g. display it next to the item it is a memo for on a web page, in plain text, etc.). Then, you should take care to properly escape and/or encode it when it comes out of the database en route to its other use.
In general, it's best to regard the database text fields as untrustworthy dens of iniquity that must be treated just like inbound CGI params (whence those fields usually came).
Finally, there is another option: filter it coming in so that it can contain only safe things for its intended purpose. However, this should generally only be done in rather limited circumstances.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Security with a MEMO field
by other90percent (Sexton) on Jun 10, 2005 at 08:03 UTC |