diff --git a/inc/field/emailfield.class.php b/inc/field/emailfield.class.php index 5dea74fca..68d0b9c7c 100644 --- a/inc/field/emailfield.class.php +++ b/inc/field/emailfield.class.php @@ -150,7 +150,7 @@ public function lessThan($value): bool { } public function regex($value): bool { - return (preg_grep($value, $this->value)) ? true : false; + return (preg_match($value, $this->value) === 1) ? true : false; } public function isPublicFormCompatible(): bool { diff --git a/inc/field/floatfield.class.php b/inc/field/floatfield.class.php index faa53a781..17c9f50b0 100644 --- a/inc/field/floatfield.class.php +++ b/inc/field/floatfield.class.php @@ -268,7 +268,7 @@ public function lessThan($value): bool { } public function regex($value): bool { - return (preg_grep($value, $this->value)) ? true : false; + return (preg_match($value, $this->value) === 1) ? true : false; } public function isPublicFormCompatible(): bool { diff --git a/inc/field/hiddenfield.class.php b/inc/field/hiddenfield.class.php index 00942d72a..c6aff20f3 100644 --- a/inc/field/hiddenfield.class.php +++ b/inc/field/hiddenfield.class.php @@ -140,7 +140,7 @@ public function lessThan($value): bool { } public function regex($value): bool { - return (preg_grep($value, $this->value)) ? true : false; + return (preg_match($value, $this->value) === 1) ? true : false; } public function isPublicFormCompatible(): bool { diff --git a/inc/field/hostnamefield.class.php b/inc/field/hostnamefield.class.php index 5b494aa2e..068b7e723 100644 --- a/inc/field/hostnamefield.class.php +++ b/inc/field/hostnamefield.class.php @@ -145,7 +145,7 @@ public function lessThan($value): bool { } public function regex($value): bool { - return (preg_grep($value, $this->value)) ? true : false; + return (preg_match($value, $this->value) === 1) ? true : false; } public function isPublicFormCompatible(): bool { diff --git a/inc/field/integerfield.class.php b/inc/field/integerfield.class.php index 85e4c292f..006b8aba2 100644 --- a/inc/field/integerfield.class.php +++ b/inc/field/integerfield.class.php @@ -150,10 +150,6 @@ public function greaterThan($value): bool { return ((int) $this->value) > ((int) $value); } - public function regex($value): bool { - return (preg_grep($value, (int) $this->value)) ? true : false; - } - public function getHtmlIcon() { return ''; } diff --git a/inc/field/ipfield.class.php b/inc/field/ipfield.class.php index c16cccb8a..bc8c34264 100644 --- a/inc/field/ipfield.class.php +++ b/inc/field/ipfield.class.php @@ -156,7 +156,7 @@ public function lessThan($value): bool { } public function regex($value): bool { - return (preg_grep($value, $this->value)) ? true : false; + return (preg_match($value, $this->value) === 1) ? true : false; } public function isPublicFormCompatible(): bool { diff --git a/inc/field/textareafield.class.php b/inc/field/textareafield.class.php index 7f6c12532..0b89ddb5c 100644 --- a/inc/field/textareafield.class.php +++ b/inc/field/textareafield.class.php @@ -240,7 +240,7 @@ public function lessThan($value): bool { } public function regex($value): bool { - return (preg_grep($value, $this->value)) ? true : false; + return (preg_match(Sanitizer::unsanitize($value), $this->value) === 1) ? true : false; } public function isPublicFormCompatible(): bool {