From 3b282f3903926d8e87a7d15699c9ae4df6a0b68a Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Sat, 13 Jun 2020 14:36:44 +0200 Subject: [PATCH] Fix step validation of number field Will allow validation of number fields with step that's not an integer. HTML5 fields allow steps to be float numbers. --- h5p.classes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index a6104313..f5f1e497 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -3754,7 +3754,7 @@ public function validateNumber(&$number, $semantics) { // Check if number is within allowed bounds even if step value is set. if (isset($semantics->step)) { $testNumber = $number - (isset($semantics->min) ? $semantics->min : 0); - $rest = $testNumber % $semantics->step; + $rest = fmod($testNumber, $semantics->step); if ($rest !== 0) { $number -= $rest; }