From 24e02f8d88af1b4236963262313f54af49cd8e80 Mon Sep 17 00:00:00 2001 From: Mark Cavage Date: Wed, 30 Jan 2013 23:50:19 +0000 Subject: [PATCH] throw on all bad filters --- lib/filters/index.js | 4 ++++ package.json | 2 +- test/filters/parse.test.js | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/filters/index.js b/lib/filters/index.js index 62782f5..d807108 100644 --- a/lib/filters/index.js +++ b/lib/filters/index.js @@ -114,6 +114,10 @@ function _buildFilterTree(expr) { var operatorStr = ''; tree.name = ''; tree.value = ''; + + if (!/[a-zA-Z0-9;\-]+[~><:]?=.+/.test(expr)) + throw new Error(expr + ' is invalid'); + if (expr.indexOf('~=') !== -1) { operatorStr = '~='; tree.tag = 'approxMatch'; diff --git a/package.json b/package.json index e2e1a3d..ee7218b 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "name": "ldapjs", "homepage": "http://ldapjs.org", "description": "LDAP client and server APIs", - "version": "0.5.8", + "version": "0.5.9", "repository": { "type": "git", "url": "git://github.com/mcavage/node-ldapjs.git" diff --git a/test/filters/parse.test.js b/test/filters/parse.test.js index 6302cc0..7851f9f 100644 --- a/test/filters/parse.test.js +++ b/test/filters/parse.test.js @@ -130,3 +130,10 @@ test('bogus filter', function (t) { }); t.end(); }); + +test('bogus filter !=', function (t) { + t.throws(function () { + parse('foo!=1'); + }); + t.end(); +});