From 51e6abf477745c22ef0e1c72e856d141c1e664d9 Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Thu, 11 Oct 2012 20:04:10 +0000 Subject: [PATCH] throw on invalid filter syntax --- bin/ldapjs-search | 1 - lib/filters/index.js | 3 ++- test/filters/parse.test.js | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/ldapjs-search b/bin/ldapjs-search index 66853bd..bfd854c 100755 --- a/bin/ldapjs-search +++ b/bin/ldapjs-search @@ -95,7 +95,6 @@ function perror(err) { ///--- Mainline -log4js.setGlobalLogLevel('INFO'); var parsed; try { diff --git a/lib/filters/index.js b/lib/filters/index.js index 476396f..62782f5 100644 --- a/lib/filters/index.js +++ b/lib/filters/index.js @@ -130,7 +130,8 @@ function _buildFilterTree(expr) { operatorStr = '='; tree.tag = 'equalityMatch'; } else { - tree.tag = 'present'; + // tree.tag = 'present'; + throw new Error('invalid filter syntax'); } if (operatorStr === '') { diff --git a/test/filters/parse.test.js b/test/filters/parse.test.js index 6e7ab8c..6302cc0 100644 --- a/test/filters/parse.test.js +++ b/test/filters/parse.test.js @@ -116,10 +116,17 @@ test('GH-53 NotFilter', function (t) { test('presence filter', function (t) { - var str = '(foo=*)'; - var f = parse(str); + var f = parse('(foo=*)'); t.ok(f); t.equal(f.type, 'present'); t.equal(f.attribute, 'foo'); t.end(); }); + + +test('bogus filter', function (t) { + t.throws(function () { + parse('foo>1'); + }); + t.end(); +});