diff --git a/admin/inc/class.admin_customfields.inc.php b/admin/inc/class.admin_customfields.inc.php index 76052ceaa3..2387bb9503 100644 --- a/admin/inc/class.admin_customfields.inc.php +++ b/admin/inc/class.admin_customfields.inc.php @@ -279,6 +279,13 @@ class admin_customfields $this->tmpl->exec($exec,$content,$sel_options,$readonlys,$preserve); } + /** + * Check selectbox values to match regular expression in et2_widget_selectbox.js: _is_multiple_regexp + * + * If values do not match, comma-separated values are not split by comma! + */ + const CHECK_MULTISELCT_VALUE = '/^[0-9A-Za-z\/_ -]+$/'; + /** * Edit/Create Custom fields with type * @@ -346,6 +353,14 @@ class admin_customfields { list($var_raw,$value) = explode('=',trim($line),2); $var = trim($var_raw); + if (!preg_match(self::CHECK_MULTISELCT_VALUE, $var)) + { + Api\Etemplate::set_validation_error('cf_values', + lang('Invalide value "%1", use only:', $var)."\n". + preg_replace('/^.*\[([^]]+)\].*$/', '$1', self::CHECK_MULTISELCT_VALUE)); + $action = 'apply'; // do not close the window to show validation error + if (!$cf_id) break 2; // only stop storing of new CFs + } $values[$var] = trim($value)==='' ? $var : $value; } } diff --git a/api/js/etemplate/et2_widget_selectbox.js b/api/js/etemplate/et2_widget_selectbox.js index 4614f52db9..427eecde88 100644 --- a/api/js/etemplate/et2_widget_selectbox.js +++ b/api/js/etemplate/et2_widget_selectbox.js @@ -502,7 +502,7 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend( /** * Regular expression, to check string-value contains multiple comma-separated values */ - _is_multiple_regexp: /^[,0-9A-Za-z/_-]+$/, + _is_multiple_regexp: /^[,0-9A-Za-z/_ -]+$/, /** * Regular expression and replace value for escaping values in jQuery selectors used to find options