filter parsing not catching (()

This commit is contained in:
Mark Cavage 2013-02-07 18:16:40 +00:00
parent 1e796624cb
commit 3fc422ac2b
3 changed files with 18 additions and 4 deletions

View File

@ -52,7 +52,11 @@ function matchParens(str, openParenIndex) {
esc = false;
}
return str.length - 1;
var ndx = str.length - 1;
if (str.charAt(ndx) !== ')')
throw new Error(str + ' has unbalanced parentheses');
return ndx;
}
@ -99,6 +103,7 @@ function _buildFilterTree(expr) {
// out (at least for this recursion level)
while (expr.length !== 0) {
endParen = matchParens(expr);
if (endParen == expr.length - 1) {
tree.children[i] = _buildFilterTree(expr);
expr = '';

View File

@ -11,7 +11,7 @@
"name": "ldapjs",
"homepage": "http://ldapjs.org",
"description": "LDAP client and server APIs",
"version": "0.6.1",
"version": "0.6.2",
"repository": {
"type": "git",
"url": "git://github.com/mcavage/node-ldapjs.git"
@ -29,9 +29,9 @@
"assert-plus": "0.1.2",
"buffertools": "1.1.0",
"bunyan": "0.18.2",
"dtrace-provider": "0.2.7",
"dtrace-provider": "0.2.8",
"nopt": "2.1.1",
"pooling": "0.3.2"
"pooling": "0.4.1"
},
"devDependencies": {
"tap": "0.4.0",

View File

@ -139,9 +139,18 @@ test('bogus filter', function (t) {
t.end();
});
test('bogus filter !=', function (t) {
t.throws(function () {
parse('foo!=1');
});
t.end();
});
test('mismatched parens', function (t) {
t.throws(function () {
parse('(&(foo=bar)(!(state=done))');
});
t.end();
});