From a24ec590fad8fe2c174042bc00424f35d039a31b Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Tue, 29 Jul 2014 11:16:26 -0500 Subject: [PATCH] forms: Phone numbers with no digits = invalid Previously, the characters would be removed and the data would be considered empty which would bypass validation and clear the phone number on save rather than triggering a validation error. --- include/class.forms.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/class.forms.php b/include/class.forms.php index e86a07dd0..e782f3ef2 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -662,7 +662,9 @@ class PhoneField extends FormField { function parse($value) { // NOTE: Value may have a legitimate 'X' to separate the number and // extension parts. Don't remove the 'X' - return preg_replace('/[^\dX]/', '', $value); + $val = preg_replace('/[^\dX]/', '', $value); + // Pass completely-incorrect string for validation error + return $val ?: $value; } function toString($value) { -- GitLab