throw on all bad filters

This commit is contained in:
Mark Cavage 2013-01-30 23:50:19 +00:00
parent f87f608c05
commit 24e02f8d88
3 changed files with 12 additions and 1 deletions

View File

@ -114,6 +114,10 @@ function _buildFilterTree(expr) {
var operatorStr = ''; var operatorStr = '';
tree.name = ''; tree.name = '';
tree.value = ''; tree.value = '';
if (!/[a-zA-Z0-9;\-]+[~><:]?=.+/.test(expr))
throw new Error(expr + ' is invalid');
if (expr.indexOf('~=') !== -1) { if (expr.indexOf('~=') !== -1) {
operatorStr = '~='; operatorStr = '~=';
tree.tag = 'approxMatch'; tree.tag = 'approxMatch';

View File

@ -10,7 +10,7 @@
"name": "ldapjs", "name": "ldapjs",
"homepage": "http://ldapjs.org", "homepage": "http://ldapjs.org",
"description": "LDAP client and server APIs", "description": "LDAP client and server APIs",
"version": "0.5.8", "version": "0.5.9",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/mcavage/node-ldapjs.git" "url": "git://github.com/mcavage/node-ldapjs.git"

View File

@ -130,3 +130,10 @@ test('bogus filter', function (t) {
}); });
t.end(); t.end();
}); });
test('bogus filter !=', function (t) {
t.throws(function () {
parse('foo!=1');
});
t.end();
});