Skip to content

Commit

Permalink
Fixes a bug where string equality matches could be manipulated by reg…
Browse files Browse the repository at this point in the history
…ex metacharacters
  • Loading branch information
Ben Ng committed Jul 1, 2013
1 parent 31af941 commit b9d5daf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/adapters/mongo/index.js
Expand Up @@ -107,6 +107,7 @@ utils.mixin(Adapter.prototype, new (function () {
// Case-insensitive equality via regex
if (nocase) {
val = val.toLowerCase();
val = utils.string.escapeRegExpChars(val);
re = new RegExp('^' + val + '$', 'i');
ret[comp.field] = re;
}
Expand Down
10 changes: 10 additions & 0 deletions test/integration/adapters/shared.js
Expand Up @@ -174,6 +174,16 @@ tests = {
});
}

, 'test all, by string with metacharacters equality': function (next) {
Zooby.all({foo: '.*'}, {nocase:true}, function (err, data) {
if (err) {
throw err;
}
assert.equal(0, data.length);
next();
});
}

, 'test all, by string case-insensitive bool': function (next) {
Zooby.all({foo:'BAR'}, {nocase: true}, function (err, data) {
if (err) {
Expand Down

0 comments on commit b9d5daf

Please sign in to comment.