note 102907 added to security.magicquotes
| From: | cHao at osu1 dot php dot net | Date: | Mon, 14 Mar 2011 16:38:54 +0000 |
| Subject: | note 102907 added to security.magicquotes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-177857@lists.php.net to get a copy of this message | ||
The very reason magic quotes are deprecated is that a one-size-fits-all approach to escaping/quoting
is wrongheaded and downright dangerous. Different types of content have different special chars and
different ways of escaping them, and what works in one tends to have side effects elsewhere. Any
sample code, here or anywhere else, that pretends to work like magic quotes --or does a similar
conversion for HTML, SQL, or anything else for that matter -- is similarly wrongheaded and similarly
dangerous.
Magic quotes are not for security. They never have been. It's a convenience thing -- they
exist so a PHP noob can fumble along and eventually write some mysql queries that kinda work,
without having to learn about escaping/quoting data properly. They prevent a few accidental syntax
errors, as is their job. But they won't stop a malicious and semi-knowledgeable attacker from
trashing the PHP noob's database. And that poor noob may never even know how or why his
database is now gone, because magic quotes (or his spiffy "i'm gonna escape
everything" function) gave him a false sense of security. He never had to learn how to really
handle untrusted input.
Data should be escaped where you need it escaped, and for the domain in which it will be used.
(mysql_real_escape_string -- NOT addslashes! -- for MySQL (and that's only unless you have a
clue and use prepared statements), htmlentities or htmlspecialchars for HTML, etc.) Anything else
is doomed to failure.
----
Server IP: 69.147.83.197
Probable Submitter: 173.15.197.30
----
Manual Page -- http://www.php.net/manual/en/security.magicquotes.php
Edit -- https://master.php.net/note/edit/102907
Del: integrated -- https://master.php.net/note/delete/102907/integrated
Del: useless -- https://master.php.net/note/delete/102907/useless
Del: bad code -- https://master.php.net/note/delete/102907/bad+code
Del: spam -- https://master.php.net/note/delete/102907/spam
Del: non-english -- https://master.php.net/note/delete/102907/non-english
Del: in docs -- https://master.php.net/note/delete/102907/in+docs
Del: other reasons-- https://master.php.net/note/delete/102907
Reject -- https://master.php.net/note/reject/102907
Search -- https://master.php.net/manage/user-notes.php