note 72402 added to security.magicquotes
| From: | php-general at lists dot php dot net | Date: | Wed, 17 Jan 2007 17:37:20 +0000 |
| Subject: | note 72402 added to security.magicquotes | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121841@lists.php.net to get a copy of this message | ||
I think most of the people posting below are a little confused about how this works...
To the person who said use addslashes rather than stripslashes... Well, the prefered use of
MAGIC_QUOTES_GPC is off, so if you are designing code in such a manner well, using addlashes is of
course going to do the same thing as having it turned on. DUH!
Next on the agenda, is the guy who posted the code which the above anonymous person(s) made a
comment about. Good, except design your code to not use the HTTP_GET_VARS etc at all, PHP3 is
completely outdated... Turn off these options in your .INI/.htaccess/registry files (etc) as well!
Additionally, I do not believe that MAGIC_QUOTES affects $_SERVER or $_ENV. I also don't think
it affects $_FILES however these values ARE submitted from the user therefor may get escaped.
Heres some code directly from a CMS I'm working on.
# strips slashes to a multi dimensional array, by reference
function stripslashes_arrays(&$array) {
if ( is_array($array) ) {
$keys = array_keys($array);
foreach ( $keys as $key ) {
if ( is_array($array[$key]) ) {
stripslashes_arrays($array[$key]);
}
else {
$array[$key] = stripslashes($array[$key]);
}
}
}
}
# --- Handle input var escapes
# magic_quotes_runtime is some retarded shit and could corrupt data,
# so make sure it's turned off...
set_magic_quotes_runtime(0);
# All escapes are handled from code...
# So rather, strip slashes if magic quotes is enabled
if( get_magic_quotes_gpc() ) {
stripslashes_arrays($_GET);
stripslashes_arrays($_POST);
stripslashes_arrays($_COOKIE);
# stripslashes_arrays($_FILES);
# verify $_FILES gets escapes by MAGIC_QUOTES first
}
----
Server IP: 69.147.83.197
Probable Submitter: 71.160.159.222
----
Manual Page -- http://www.php.net/manual/en/security.magicquotes.php
Edit -- https://master.php.net/note/edit/72402
Del: integrated -- https://master.php.net/note/delete/72402/integrated
Del: useless -- https://master.php.net/note/delete/72402/useless
Del: bad code -- https://master.php.net/note/delete/72402/bad+code
Del: spam -- https://master.php.net/note/delete/72402/spam
Del: non-english -- https://master.php.net/note/delete/72402/non-english
Del: in docs -- https://master.php.net/note/delete/72402/in+docs
Del: other reasons-- https://master.php.net/note/delete/72402
Reject -- https://master.php.net/note/reject/72402
Search -- https://master.php.net/manage/user-notes.php