Skip to content

Commit

Permalink
Issue #4671 : validator with fraction on numeric question can fail wi…
Browse files Browse the repository at this point in the history
…th .0

Dev : replace the sanitize_float function

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey@9256 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Shnoulle committed Oct 16, 2010
1 parent 4027017 commit 5865131
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions classes/core/sanitize.php
Expand Up @@ -62,6 +62,7 @@
// 20070213 lemeur - marked sanitize_sql_string as obsolete, should use db_quote instead
// 20071025 c_schmitz - added sanitize_email
// 20071032 lemeur - added sanitize_user and sanitize_userfullname
// 20101016 shnoulle - modify sanitize_float to keep n.0
//
/////////////////////////////////////////

Expand Down Expand Up @@ -284,10 +285,11 @@ function sanitize_labelname($string)
return $string;
}

// make float float!
// make float float! but with .0
function sanitize_float($float, $min='', $max='')
{
$float = floatval($float);
//$float = floatval($float);
$float = filter_var($float, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if((($min != '') && ($float < $min)) || (($max != '') && ($float > $max)))
return FALSE;
return $float;
Expand Down

0 comments on commit 5865131

Please sign in to comment.