diff --git a/src/opnsense/www/js/tokenize2.js b/src/opnsense/www/js/tokenize2.js index 51617efe2..483ef46c0 100644 --- a/src/opnsense/www/js/tokenize2.js +++ b/src/opnsense/www/js/tokenize2.js @@ -282,8 +282,8 @@ */ Tokenize2.prototype.tokenAdd = function(value, text, force){ - value = this.escape(value); - text = this.escape(text) || value; + text = text || value; + selector_value = $.escapeSelector(value); force = force || false; this.resetInput(); @@ -300,17 +300,17 @@ } // Check duplicate token - if($('li.token[data-value="' + value + '"]', this.tokensContainer).length > 0){ + if($('li.token[data-value="' + selector_value + '"]', this.tokensContainer).length > 0){ this.trigger('tokenize:tokens:error:duplicate', [value, text]); return this; } - if($('option[value="' + value + '"]', this.element).length) { - $('option[value="' + value + '"]', this.element).attr('selected', 'selected').prop('selected', true); + if($('option[value="' + selector_value + '"]', this.element).length) { + $('option[value="' + selector_value + '"]', this.element).attr('selected', 'selected').prop('selected', true); } else if(force){ - this.element.append($('