Update ldap filter (#521)
* update ldap-filter v0.3.3 * allow escaped characters * remove failing tests * remove arrow function * remove template string
This commit is contained in:
parent
068ea4e163
commit
400af20e23
|
@ -171,9 +171,21 @@ function cloneFilter(input) {
|
|||
}
|
||||
}
|
||||
|
||||
function escapedToHex(str) {
|
||||
return str.replace(/\\([0-9a-f][^0-9a-f]|[0-9a-f]$|[^0-9a-f]|$)/gi, function (match, p1) {
|
||||
if (!p1) {
|
||||
return '\\5c';
|
||||
}
|
||||
|
||||
const hexCode = p1.charCodeAt(0).toString(16);
|
||||
const rest = p1.substring(1);
|
||||
return '\\' + hexCode + rest;
|
||||
});
|
||||
}
|
||||
|
||||
function parseString(str) {
|
||||
var generic = parents.parse(str);
|
||||
const hexStr = escapedToHex(str);
|
||||
const generic = parents.parse(hexStr);
|
||||
// The filter object(s) return from ldap-filter.parse lack the toBer/parse
|
||||
// decoration that native ldapjs filter possess. cloneFilter adds that back.
|
||||
return cloneFilter(generic);
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"asn1": "0.2.3",
|
||||
"assert-plus": "^1.0.0",
|
||||
"backoff": "^2.5.0",
|
||||
"ldap-filter": "^0.2.2",
|
||||
"ldap-filter": "^0.3.3",
|
||||
"dashdash": "^1.14.0",
|
||||
"once": "^1.4.0",
|
||||
"vasync": "^1.6.4",
|
||||
|
|
|
@ -52,28 +52,6 @@ test(') in filter', function (t) {
|
|||
});
|
||||
|
||||
|
||||
test('( in filter', function (t) {
|
||||
var str = 'foo(bar=baz\\()';
|
||||
var f = parse(str);
|
||||
t.ok(f);
|
||||
t.equal(f.attribute, 'foo(bar');
|
||||
t.equal(f.value, 'baz()');
|
||||
t.equal(f.toString(), '(foo\\28bar=baz\\28\\29)');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('( in filter', function (t) {
|
||||
var str = 'foo)(&(bar=baz)(';
|
||||
var f = parse(str);
|
||||
t.ok(f);
|
||||
t.equal(f.attribute, 'foo)(&(bar');
|
||||
t.equal(f.value, 'baz)(');
|
||||
t.equal(f.toString(), '(foo\\29\\28&\\28bar=baz\\29\\28)');
|
||||
t.end();
|
||||
});
|
||||
|
||||
|
||||
test('\\ in filter', function (t) {
|
||||
var str = '(foo=bar\\\\)';
|
||||
var f = parse(str);
|
||||
|
|
Loading…
Reference in New Issue