Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit fa6ffb4

Browse files
authored
Merge branch 'next' into next-vls-controls
2 parents bc660e1 + dd2a722 commit fa6ffb4

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lib/filters/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,13 @@ function cloneFilter (input) {
165165
}
166166

167167
function escapedToHex (str) {
168-
return str.replace(/\\([0-9a-f][^0-9a-f]|[0-9a-f]$|[^0-9a-f]|$)/gi, function (match, p1) {
168+
return str.replace(/\\([0-9a-f](?![0-9a-f])|[^0-9a-f]|$)/gi, function (match, p1) {
169169
if (!p1) {
170170
return '\\5c'
171171
}
172172

173173
const hexCode = p1.charCodeAt(0).toString(16)
174-
const rest = p1.substring(1)
175-
return '\\' + hexCode + rest
174+
return '\\' + hexCode
176175
})
177176
}
178177

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "ldapjs",
44
"homepage": "http://ldapjs.org",
55
"description": "LDAP client and server APIs",
6-
"version": "2.0.0-pre.1",
6+
"version": "2.0.0-pre.2",
77
"license": "MIT",
88
"repository": {
99
"type": "git",

test/filters/parse.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ test('GH-50 = in filter', function (t) {
2626
t.end()
2727
})
2828

29+
test('convert to hex code', function (t) {
30+
const str = 'foo=bar\\(abcd\\e\\fg\\h\\69\\a'
31+
const f = parse(str)
32+
t.ok(f)
33+
t.equal(f.attribute, 'foo')
34+
t.equal(f.value, 'bar(abcdefghia')
35+
t.equal(f.toString(), '(foo=bar\\28abcdefghia)')
36+
t.end()
37+
})
38+
2939
test('( in filter', function (t) {
3040
const str = '(foo=bar\\()'
3141
const f = parse(str)
@@ -56,6 +66,16 @@ test('\\ in filter', function (t) {
5666
t.end()
5767
})
5868

69+
test('not escaped \\ at end of filter', function (t) {
70+
const str = 'foo=bar\\'
71+
const f = parse(str)
72+
t.ok(f)
73+
t.equal(f.attribute, 'foo')
74+
t.equal(f.value, 'bar\\')
75+
t.equal(f.toString(), '(foo=bar\\5c)')
76+
t.end()
77+
})
78+
5979
test('* in equality filter', function (t) {
6080
const str = '(foo=bar\\*)'
6181
const f = parse(str)

0 commit comments

Comments
 (0)