Skip to content

Commit 0bfbaaf

Browse files
author
Marius Cramer
committed
Added: new validator ISASCII to forbid non-ascii characters
1 parent 2ed8f05 commit 0bfbaaf

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

interface/lib/classes/remoting_lib.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,15 @@ function validateField($field_name, $field_value, $validators) {
511511
}
512512
}
513513
break;
514+
case 'ISASCII':
515+
if(preg_match("/[^\x20-\x7F]/", $field_value)) {
516+
$errmsg = $validator['errmsg'];
517+
if(isset($this->wordbook[$errmsg])) {
518+
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
519+
} else {
520+
$this->errorMessage .= $errmsg."<br />\r\n";
521+
}
522+
}
514523
case 'ISEMAIL':
515524
if(function_exists('filter_var')) {
516525
if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) {

interface/lib/classes/tform.inc.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,6 +845,15 @@ function validateField($field_name, $field_value, $validators) {
845845
}
846846
}
847847
break;
848+
case 'ISASCII':
849+
if(preg_match("/[^\x20-\x7F]/", $field_value)) {
850+
$errmsg = $validator['errmsg'];
851+
if(isset($this->wordbook[$errmsg])) {
852+
$this->errorMessage .= $this->wordbook[$errmsg]."<br />\r\n";
853+
} else {
854+
$this->errorMessage .= $errmsg."<br />\r\n";
855+
}
856+
}
848857
case 'ISEMAIL':
849858
if(function_exists('filter_var')) {
850859
if(filter_var($field_value, FILTER_VALIDATE_EMAIL) === false) {

0 commit comments

Comments
 (0)