Avatar

magic_quotes_gpc (Bugs)

by Auge ⌂ @, Wednesday, January 27, 2010, 10:24 (3890 days ago) @ Alex

Hello

Is it possible, that "REQUEST" is not contained in the global array?

In most cases the superglobal array REQUEST is present. Maybe your hoster disabled it, because it contains only the merged data of other superglobal arrays (GET, POST, COOKIE, SESSION, FILE ..., SERVER(?)).

Hm... no idea! IMHO the better way is to do it the other way round: strip slashes if magic_quotes_gpc is enabled (which shouldn't be the case anymore).

Additional information: with PHP 6 the magic quotes are not existent anymore.

// stripslashes on GPC if magic_quotes_gpc is enabled: 
if(get_magic_quotes_gpc()) 
{
function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);
return $value;
}
$_POST = array_map('stripslashes_deep', $_POST);
$_GET = array_map('stripslashes_deep', $_GET);
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}

Be aware that all (old) postings can contain added backslashes. New postings havent but wanted backslashes (i.e. in code examples) in new postings will be deleted (dynamically) when the posting is displayed. This is because the script handles the backslashes the old way (add and strip) but new postings have only wanted backslashes.

Old behaviour:
"\n"->request (input)->'"\\n" via magic_quotes [b]or[/b] addslashes()'->'"\\n" in DB'->request (output)->stripslashes()->"\n"
New behaviour:
"\n"->request (input)->'stripslashes() in case of magic_quotes'->'"\n" in DB'->request (output)->stripslashes()->"n"

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!


Complete thread:

 RSS Feed of thread

powered by my little forum