From 1a45c87c478847e11e3e78cf89a9df7227bf246e Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 26 Sep 2007 17:59:29 +0000 Subject: [PATCH] Make wfIniGetBool() more accurate: * accepts 'yes' as well as 'on' and 'true' * accepts negative and non-1 integers, as well as garbage characters after the number (as C atoi() function for nonzero result) --- includes/GlobalFunctions.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index a67972ded0..b216eca9b3 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -1783,7 +1783,7 @@ function wfUrlProtocols() { * for code that just takes the ini_get() return value as a boolean. * * To make things extra interesting, setting via php_value accepts - * "true" as true, but php.ini and php_flag consider it false. :) + * "true" and "yes" as true, but php.ini and php_flag consider them false. :) * Unrecognized values go false... again opposite PHP's own coercion * from string to bool. * @@ -1798,9 +1798,10 @@ function wfUrlProtocols() { function wfIniGetBool( $setting ) { $val = ini_get( $setting ); // 'on' and 'true' can't have whitespace around them, but '1' can. - return trim( $val ) == '1' - || strtolower( $val ) == 'on' - || strtolower( $val ) == 'true'; + return strtolower( $val ) == 'on' + || strtolower( $val ) == 'true' + || strtolower( $val ) == 'yes' + || preg_match( "/^\s*[+-]?0*[1-9]/", $val ); // approx C atoi() function } /** -- 2.20.1