From 9f4a51819e99be6388b10dd852ef32d24bc47d51 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Sun, 8 Feb 2026 01:22:38 +0100 Subject: [PATCH] Avoid deprecated each (fix #1218) --- adminer/include/bootstrap.inc.php | 6 +++++- adminer/include/functions.inc.php | 25 ++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/adminer/include/bootstrap.inc.php b/adminer/include/bootstrap.inc.php index f2bbc0fa..bea89f2d 100644 --- a/adminer/include/bootstrap.inc.php +++ b/adminer/include/bootstrap.inc.php @@ -61,7 +61,11 @@ if (!defined("SID")) { } // disable magic quotes to be able to use database escaping function -remove_slashes(array(&$_GET, &$_POST, &$_COOKIE), $filter); +if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) { + $_GET = remove_slashes($_GET, $filter); + $_POST = remove_slashes($_POST, $filter); + $_COOKIE = remove_slashes($_COOKIE, $filter); +} if (function_exists("get_magic_quotes_runtime") && get_magic_quotes_runtime()) { set_magic_quotes_runtime(false); } diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 3177dcc3..1308c9b8 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -76,24 +76,19 @@ function number_type(): string { } /** Disable magic_quotes_gpc -* @param list $process e.g. [&$_GET, &$_POST, &$_COOKIE] +* @param mixed[] $values * @param bool $filter whether to leave values as is -* @return void modified in place +* @return mixed[] */ -function remove_slashes(array $process, bool $filter = false): void { - if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc()) { - while (list($key, $val) = each($process)) { - foreach ($val as $k => $v) { - unset($process[$key][$k]); - if (is_array($v)) { - $process[$key][stripslashes($k)] = $v; - $process[] = &$process[$key][stripslashes($k)]; - } else { - $process[$key][stripslashes($k)] = ($filter ? $v : stripslashes($v)); - } - } - } +function remove_slashes(array $values, bool $filter = false): array { + $return = array(); + foreach ($values as $key => $val) { + $return[stripslashes($key)] = (is_array($val) + ? remove_slashes($val, $filter) + : ($filter ? $val : stripslashes($val)) + ); } + return $return; } /** Escape or unescape string to use inside form [] */