From ec2fc6ddd05adfd92a7b0fd51bff4daa14309ee5 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Tue, 24 Jan 2012 11:29:05 -0600 Subject: [PATCH] fixed infinite loop when removing magic. --- laravel/helpers.php | 12 ++++++------ laravel/laravel.php | 7 +++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/laravel/helpers.php b/laravel/helpers.php index 0bf4f11e..0bad860b 100644 --- a/laravel/helpers.php +++ b/laravel/helpers.php @@ -97,7 +97,7 @@ function array_set(&$array, $key, $value) // If the key doesn't exist at this depth, we will just create an // empty array to hold the next value, allowing us to create the - // arrays necessary to hold the final value at the proper depth. + // arrays to hold the final value at the proper depth. if ( ! isset($array[$key]) or ! is_array($array[$key])) { $array[$key] = array(); @@ -197,10 +197,10 @@ function array_spin($array, $callback) */ function array_strip_slashes($array) { + $result = array(); + foreach($array as $key => $value) { - unset($array[$key]); - $key = stripslashes($key); // If the value is an array, we will just recurse back into the @@ -208,15 +208,15 @@ function array_strip_slashes($array) // otherwise we will set the stripped value. if (is_array($value)) { - $array[$key] = array_strip_slashes($value); + $result[$key] = array_strip_slashes($value); } else { - $array[$key] = stripslashes($value); + $result[$key] = stripslashes($value); } } - return $array; + return $result; } /** diff --git a/laravel/laravel.php b/laravel/laravel.php index 34999f83..be4fc93c 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -67,9 +67,12 @@ */ if (magic_quotes()) { - $magic = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); + $magics = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); - array_walk($magic, 'array_strip_slashes'); + foreach ($magics as &$magic) + { + $magic = array_strip_slashes($magic); + } } /**