From 3af6e0baefbeb144dea0490e05218a91a616103e Mon Sep 17 00:00:00 2001 From: Stephen Shkardoon Date: Mon, 2 Jan 2012 23:40:02 +1100 Subject: Bug where configuration file was escaped incorrectly Bug where a timeout of 0 was incorrectly recognized --- lib/debug.lib.php | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'lib/debug.lib.php') diff --git a/lib/debug.lib.php b/lib/debug.lib.php index e6636976..928b4f8d 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -225,12 +225,8 @@ function check_php_memory() { */ function check_php_timelimit() { - $current = ini_get('max_execution_time'); - if (intval($current) < 60) { - return false; - } - - return true; + $current = intval(ini_get('max_execution_time')); + return ($current > 60 || $current == 0); } // check_php_timelimit @@ -352,10 +348,10 @@ function generate_config($current) { /* Put in the current value */ if ($key == 'config_version') { - $line = $key . ' = ' . addslashes($value); + $line = $key . ' = ' . escape_ini($value); } elseif (isset($current[$key])) { - $line = $key . ' = "' . addslashes($current[$key]) . '"'; + $line = $key . ' = "' . escape_ini($current[$key]) . '"'; unset($current[$key]); } // if set @@ -369,6 +365,18 @@ function generate_config($current) { } // generate_config +/** + * escape_ini + * Escape a value used for inserting into an ini file. + * Won't quote ', like addslashes does. + */ +function escape_ini($str) { + + return str_replace('"', '\"', $str); + +} + + /** * debug_ok * Return an "OK" with the specified string -- cgit