fixed broken regular expression for multiple comma-separated values (dash in character class has to be last character!)

This commit is contained in:
Ralf Becker 2014-07-13 09:14:58 +00:00
parent 8c6ac14093
commit f011a6c3d1
2 changed files with 15 additions and 5 deletions

View File

@ -291,7 +291,7 @@ var et2_selectAccount = et2_selectbox.extend(
*/ */
set_value: function(_value) 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(','); _value = _value.split(',');
} }
@ -312,7 +312,7 @@ var et2_selectAccount = et2_selectbox.extend(
// Not having a value to look up causes an infinite loop // Not having a value to look up causes an infinite loop
if(!search[j]) continue; if(!search[j]) continue;
// Options are not indexed, so we must look // Options are not indexed, so we must look
for(var i = 0; !found && i < this.options.select_options.length; i++) for(var i = 0; !found && i < this.options.select_options.length; i++)
{ {
@ -748,7 +748,7 @@ var et2_selectAccount = et2_selectbox.extend(
.appendTo(option); .appendTo(option);
this.egw().link_title('home-accounts', value, function(name) {this.text(name).removeClass("loading");}, label); this.egw().link_title('home-accounts', value, function(name) {this.text(name).removeClass("loading");}, label);
}, },
/** /**
* Overwritten attachToDOM metod to modify attachToDOM * Overwritten attachToDOM metod to modify attachToDOM
*/ */

View File

@ -423,10 +423,20 @@ var et2_selectbox = et2_inputWidget.extend(
this.set_select_options(this.options.select_options); 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) set_value: function(_value)
{ {
if (typeof _value == "number") _value = ""+_value; // convert to string for consitent matching 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(','); _value = _value.split(',');
} }
@ -915,7 +925,7 @@ var et2_selectbox_ro = et2_selectbox.extend([et2_IDetachedDOM],
if(typeof _value == "string") 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(); this.span.empty();