Skip to content

Commit 55e2201

Browse files
committed
- Changed ISINT check; filter_var check now allows integers that are 0.
1 parent 43922aa commit 55e2201

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

interface/lib/classes/tform.inc.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ function validateField($field_name, $field_value, $validators) {
770770
break;
771771
case 'ISEMAIL':
772772
if(function_exists('filter_var')) {
773-
if(!filter_var($field_value, FILTER_VALIDATE_EMAIL)) {
773+
if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) {
774774
$errmsg = $validator['errmsg'];
775775
if(isset($this->wordbook[$errmsg])) {
776776
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
@@ -790,17 +790,16 @@ function validateField($field_name, $field_value, $validators) {
790790
}
791791
break;
792792
case 'ISINT':
793-
// Commented out the filter_var part because we do allow 0
794-
//if(function_exists('filter_var')) {
795-
// if(!filter_var($field_value, FILTER_VALIDATE_INT)) {
796-
// $errmsg = $validator['errmsg'];
797-
// if(isset($this->wordbook[$errmsg])) {
798-
// $this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
799-
// } else {
800-
// $this->errorMessage .= $errmsg."<br />\r\n";
801-
// }
802-
// }
803-
//} else {
793+
if(function_exists('filter_var')) {
794+
if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) {
795+
$errmsg = $validator['errmsg'];
796+
if(isset($this->wordbook[$errmsg])) {
797+
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
798+
} else {
799+
$this->errorMessage .= $errmsg."<br />\r\n";
800+
}
801+
}
802+
} else {
804803
$tmpval = intval($field_value);
805804
if($tmpval === 0 and !empty($field_value)) {
806805
$errmsg = $validator['errmsg'];
@@ -810,7 +809,7 @@ function validateField($field_name, $field_value, $validators) {
810809
$this->errorMessage .= $errmsg."<br />\r\n";
811810
}
812811
}
813-
//}
812+
}
814813
break;
815814
case 'ISPOSITIVE':
816815
if(!is_numeric($field_value) || $field_value <= 0){

0 commit comments

Comments
 (0)