MDL-36773 timezone inconsistency => some number support decimal other don\'t - Original patch author: Nathan Mares

This commit is contained in:
Jerome Mouneyrac 2012-11-30 10:11:55 +08:00
parent f42c34a38a
commit 8158ce79f9
2 changed files with 15 additions and 1 deletions

View File

@ -1134,7 +1134,7 @@ function clean_param($param, $type) {
case PARAM_TIMEZONE: //can be int, float(with .5 or .0) or string seperated by '/' and can have '-_'
$param = fix_utf8($param);
$timezonepattern = '/^(([+-]?(0?[0-9](\.[5|0])?|1[0-3]|1[0-2]\.5))|(99)|[[:alnum:]]+(\/?[[:alpha:]_-])+)$/';
$timezonepattern = '/^(([+-]?(0?[0-9](\.[5|0])?|1[0-3](\.0)?|1[0-2]\.5))|(99)|[[:alnum:]]+(\/?[[:alpha:]_-])+)$/';
if (preg_match($timezonepattern, $param)) {
return $param;
} else {

View File

@ -943,9 +943,23 @@ class moodlelib_testcase extends advanced_testcase {
'0' => '0',
'0.0' => '0.0',
'0.5' => '0.5',
'9.0' => '9.0',
'-9.0' => '-9.0',
'+9.0' => '+9.0',
'9.5' => '9.5',
'-9.5' => '-9.5',
'+9.5' => '+9.5',
'12.0' => '12.0',
'-12.0' => '-12.0',
'+12.0' => '+12.0',
'12.5' => '12.5',
'-12.5' => '-12.5',
'+12.5' => '+12.5',
'13.0' => '13.0',
'-13.0' => '-13.0',
'+13.0' => '+13.0',
'13.5' => '',
'+13.5' => '',
'-13.5' => '',
'0.2' => '');