GH-50 Allow = in filter strings
This commit is contained in:
parent
fb63ba2220
commit
512541bfbd
|
@ -33,15 +33,23 @@ var BerReader = asn1.BerReader;
|
|||
// specified by openParenIndex
|
||||
function matchParens(str, openParenIndex) {
|
||||
var stack = [];
|
||||
|
||||
var esc = false;
|
||||
for (var i = openParenIndex || 0; i < str.length; i++) {
|
||||
if (str.charAt(i) === '(') {
|
||||
var c = str[i];
|
||||
|
||||
if (c === '\\') {
|
||||
if (!esc)
|
||||
esc = true;
|
||||
continue;
|
||||
} else if (c === '(' && !esc) {
|
||||
stack.push(1);
|
||||
} else if (str.charAt(i) === ')') {
|
||||
} else if (c === ')' && !esc) {
|
||||
stack.pop();
|
||||
if (stack.length === 0)
|
||||
return i;
|
||||
}
|
||||
|
||||
esc = false;
|
||||
}
|
||||
|
||||
return str.length - 1;
|
||||
|
@ -58,6 +66,7 @@ function _buildFilterTree(expr) {
|
|||
if (expr.length === 0)
|
||||
return tree;
|
||||
|
||||
// Chop the parens (the call to matchParens below gets rid of the trailer)
|
||||
if (expr.charAt(0) == '(')
|
||||
expr = expr.substring(1, expr.length - 1);
|
||||
|
||||
|
@ -97,11 +106,6 @@ function _buildFilterTree(expr) {
|
|||
}
|
||||
} else {
|
||||
//else its some sort of non-logical expression, parse and return as such
|
||||
|
||||
// tag represents the name of the operator, initially this library was used
|
||||
// to encode a filter string into DSML where the tag name would be
|
||||
// <DSML:equalityMatch ...>
|
||||
// so thats why its named tag, if you were wondering...
|
||||
var operatorStr = '';
|
||||
var valueOffset = 0;
|
||||
tree.name = '';
|
||||
|
@ -134,9 +138,10 @@ function _buildFilterTree(expr) {
|
|||
tree.name = expr;
|
||||
} else {
|
||||
// pull out lhs and rhs of equality operator
|
||||
var splitAry = expr.split(operatorStr, 2);
|
||||
tree.name = splitAry[0];
|
||||
tree.value = splitAry[1];
|
||||
|
||||
var splitAry = expr.split(operatorStr);
|
||||
tree.name = splitAry.shift();
|
||||
tree.value = splitAry.join(operatorStr);
|
||||
|
||||
// substrings and extensible matching fall into the equality bin in the
|
||||
// switch above so we need more processing here
|
||||
|
@ -169,7 +174,6 @@ function _buildFilterTree(expr) {
|
|||
}
|
||||
} else if (tree.tag == 'extensibleMatch') {
|
||||
split = tree.name.split(':');
|
||||
console.log(split)
|
||||
tree.extensible = {
|
||||
matchType: split[0],
|
||||
value: tree.value
|
||||
|
|
|
@ -17,3 +17,15 @@ test('GH-48 XML Strings in filter', function(t) {
|
|||
});
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('GH-50 = in filter', function(t) {
|
||||
var str = '(uniquemember=uuid=930896af-bf8c-48d4-885c-6573a94b1853, ' +
|
||||
'ou=users, o=smartdc)';
|
||||
var f = parse(str);
|
||||
t.ok(f);
|
||||
t.equal(f.attribute, 'uniquemember');
|
||||
t.equal(f.value,
|
||||
'uuid=930896af-bf8c-48d4-885c-6573a94b1853, ou=users, o=smartdc');
|
||||
t.end();
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue