fix for magic quote fixing inside array keys

darcs-hash:20070819211952-7ad00-a1a321178ef3c5a85b2e422a01eda8066eb10588.gz
This commit is contained in:
Andreas Gohr 2007-08-19 23:19:52 +02:00
parent 1a9ae8e52e
commit 81c54349cd
1 changed files with 14 additions and 5 deletions

View File

@ -260,11 +260,20 @@ function init_creationmodes(){
*/
function remove_magic_quotes(&$array) {
foreach (array_keys($array) as $key) {
if (is_array($array[$key])) {
remove_magic_quotes($array[$key]);
}else {
$array[$key] = stripslashes($array[$key]);
}
// handle magic quotes in keynames (breaks order)
$sk = stripslashes($key);
if($sk != $key){
$array[$sk] = $array[$key];
unset($array[$key]);
$key = $sk;
}
// do recursion if needed
if (is_array($array[$key])) {
remove_magic_quotes($array[$key]);
}else {
$array[$key] = stripslashes($array[$key]);
}
}
}