filter parsing turning presence filter into substring filter

This commit is contained in:
Mark Cavage 2012-03-16 17:22:30 -07:00
parent b8c86cc7d2
commit 344cac0287
3 changed files with 12 additions and 4 deletions

View File

@ -58,9 +58,7 @@ Filter.prototype.toBer = function (ber) {
};
/*
* Test a rule against one or more values.
*/
// Test a rule against one or more values.
Filter.multi_test = function (rule, value) {
if (Array.isArray(value)) {
var response = false;

View File

@ -144,7 +144,7 @@ function _buildFilterTree(expr) {
// substrings fall into the equality bin in the
// switch above so we need more processing here
if (tree.tag === 'equalityMatch') {
if (tree.value.length === 0) {
if (tree.value === '*') {
tree.tag = 'present';
} else {

View File

@ -113,3 +113,13 @@ test('GH-53 NotFilter', function (t) {
t.equal(f.filters[1].filter.value, 'shadowAccount');
t.end();
});
test('presence filter', function (t) {
var str = '(foo=*)';
var f = parse(str);
t.ok(f);
t.equal(f.type, 'present');
t.equal(f.attribute, 'foo');
t.end();
});