From a01ed2aa436cef1ae4572e99b903b25af55b7975 Mon Sep 17 00:00:00 2001 From: JediKev Date: Fri, 12 Apr 2019 11:43:17 -0500 Subject: [PATCH] issue: Choice Validation Accept Punctuation This addresses issue mentioned in 4071 where the choice field validation is not accepting punctuations. This updates the regex to accept anything the user inputs. This introduces another issue that if the choice contains `:` in the value then it will truncate everything after. This is due to the explode method that explodes on any `:` character. This updates the explode method to return only 2 values which only explodes on one `:` character which returns the full value. --- include/class.forms.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index b2f215aa49..3cef29c99e 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1535,7 +1535,7 @@ function validateEntry($value) { 'choices' => array( function($val) { $val = str_replace('"', '', JsonDataEncoder::encode($val)); - $regex = "/^(?! )[A-z0-9 _-]+:{1}[A-z0-9 _-]+$/"; + $regex = "/^(?! )[A-z0-9 _-]+:{1}[^\n]+$/"; foreach (explode('\r\n', $val) as $v) { if (!preg_match($regex, $v)) return false; @@ -1913,7 +1913,7 @@ function getChoices($verbose=false) { $choices = explode("\n", $config['choices']); foreach ($choices as $choice) { // Allow choices to be key: value - list($key, $val) = explode(':', $choice); + list($key, $val) = explode(':', $choice, 2); if ($val == null) $val = $key; $this->_choices[trim($key)] = trim($val);