Merge branch 'next' into next-vls-controls

This commit is contained in:
Soisik Froger 2019-09-21 17:55:30 +02:00 committed by GitHub
commit fa6ffb4504
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 4 deletions

View File

@ -165,14 +165,13 @@ 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) {
return str.replace(/\\([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
return '\\' + hexCode
})
}

View File

@ -3,7 +3,7 @@
"name": "ldapjs",
"homepage": "http://ldapjs.org",
"description": "LDAP client and server APIs",
"version": "2.0.0-pre.1",
"version": "2.0.0-pre.2",
"license": "MIT",
"repository": {
"type": "git",

View File

@ -26,6 +26,16 @@ test('GH-50 = in filter', function (t) {
t.end()
})
test('convert to hex code', function (t) {
const str = 'foo=bar\\(abcd\\e\\fg\\h\\69\\a'
const f = parse(str)
t.ok(f)
t.equal(f.attribute, 'foo')
t.equal(f.value, 'bar(abcdefghia')
t.equal(f.toString(), '(foo=bar\\28abcdefghia)')
t.end()
})
test('( in filter', function (t) {
const str = '(foo=bar\\()'
const f = parse(str)
@ -56,6 +66,16 @@ test('\\ in filter', function (t) {
t.end()
})
test('not escaped \\ at end of filter', function (t) {
const str = 'foo=bar\\'
const f = parse(str)
t.ok(f)
t.equal(f.attribute, 'foo')
t.equal(f.value, 'bar\\')
t.equal(f.toString(), '(foo=bar\\5c)')
t.end()
})
test('* in equality filter', function (t) {
const str = '(foo=bar\\*)'
const f = parse(str)