Browse Source

Added missing regexp quoting.

Martin Edenhofer 12 years ago
parent
commit
f5295d319f

+ 2 - 1
app/assets/javascripts/app/lib/base/jquery.sew.js

@@ -162,7 +162,8 @@
 
 
 		var vals = this.filtered = values.filter($.proxy(function (e) {
-			var exp = new RegExp('\\W*' + this.options.token + e.val + '(\\W|$)');
+//			var exp = new RegExp('\\W*' + this.options.token + e.val + '(\\W|$)');
+      var exp = new RegExp('\\W*' + this.options.token + escapeRegExp(e.val) + '(\\W|$)');
 			if(!this.options.repeat && this.getText().match(exp)) {
 				return false;
 			}

+ 3 - 0
app/assets/javascripts/application.js

@@ -39,6 +39,9 @@ if (!console.log) {
   console.log = function(){}
 }
 
+function escapeRegExp(str) {
+  return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
+}
 
 Date.prototype.getWeek = function() {
   var onejan = new Date(this.getFullYear(),0,1);