From d1d743e4b9d62ed26d8577897b635db7a8f75697 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 13 Jul 2014 09:15:29 +0000 Subject: [PATCH] fixed broken regular expression for multiple comma-separated values (dash in character class has to be last character!) --- etemplate/js/et2_widget_selectAccount.js | 6 +++--- etemplate/js/et2_widget_selectbox.js | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/etemplate/js/et2_widget_selectAccount.js b/etemplate/js/et2_widget_selectAccount.js index 8813d4b377..a44e883b86 100644 --- a/etemplate/js/et2_widget_selectAccount.js +++ b/etemplate/js/et2_widget_selectAccount.js @@ -291,7 +291,7 @@ var et2_selectAccount = et2_selectbox.extend( */ set_value: function(_value) { - if(typeof _value == "string" && this.options.multiple && _value.match(/^[,0-9A-Za-z/-_]+$/) !== null) + if(typeof _value == "string" && this.options.multiple && _value.match(this._is_multiple_regexp) !== null) { _value = _value.split(','); } @@ -312,7 +312,7 @@ var et2_selectAccount = et2_selectbox.extend( // Not having a value to look up causes an infinite loop if(!search[j]) continue; - + // Options are not indexed, so we must look for(var i = 0; !found && i < this.options.select_options.length; i++) { @@ -748,7 +748,7 @@ var et2_selectAccount = et2_selectbox.extend( .appendTo(option); this.egw().link_title('home-accounts', value, function(name) {this.text(name).removeClass("loading");}, label); }, - + /** * Overwritten attachToDOM metod to modify attachToDOM */ diff --git a/etemplate/js/et2_widget_selectbox.js b/etemplate/js/et2_widget_selectbox.js index da86a058f7..cce0683055 100644 --- a/etemplate/js/et2_widget_selectbox.js +++ b/etemplate/js/et2_widget_selectbox.js @@ -423,10 +423,20 @@ var et2_selectbox = et2_inputWidget.extend( this.set_select_options(this.options.select_options); }, + /** + * Regular expression, to check string-value contains multiple comma-separated values + */ + _is_multiple_regexp: /^[,0-9A-Za-z/_-]+$/, + + /** + * Set value + * + * @param _value + */ set_value: function(_value) { if (typeof _value == "number") _value = ""+_value; // convert to string for consitent matching - if(typeof _value == "string" && this.options.multiple && _value.match(/^[,0-9A-Za-z/-_]+$/) !== null) + if(typeof _value == "string" && this.options.multiple && _value.match(this._is_multiple_regexp) !== null) { _value = _value.split(','); } @@ -915,7 +925,7 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM], if(typeof _value == "string") { - _value = _value.match(/^[,0-9A-Za-z]+$/) !== null ? _value.split(',') : [_value]; + _value = _value.match(this._is_multiple_regexp) !== null ? _value.split(',') : [_value]; } this.span.empty();