Skip to content

Commit

Permalink
Ensure returned value is part of specified range; fixes #1767
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Apr 14, 2017
1 parent 3a83447 commit bd589b1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ajax/getDropdownNumber.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,17 @@

} else {
if (!isset($toadd[$one_item])) {
$value = $one_item;
if (isset($_POST['min']) && $value < $_POST['min']) {
$value = $_POST['min'];
} else if (isset($_POST['max']) && $value > $_POST['max']) {
$value = $_POST['max'];
}

if (isset($_POST['unit'])) {
$txt = Dropdown::getValueWithUnit($one_item,$_POST['unit']);
$txt = Dropdown::getValueWithUnit($value, $_POST['unit']);
}
array_push($datas, array('id' => $one_item,
array_push($datas, array('id' => $value,
'text' => strval(stripslashes($txt))));
$count++;
}
Expand All @@ -133,4 +140,4 @@
$ret['count'] = $count;
echo json_encode($ret);
}
?>
?>

0 comments on commit bd589b1

Please sign in to comment.