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

Address issue #860 (cannot search with non-ascii in filter) #938

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
},
"main": "lib/index.js",
"dependencies": {
"@ldapjs/asn1": "2.0.0",
"@ldapjs/attribute": "1.0.0",
"@ldapjs/change": "1.0.0",
"@ldapjs/controls": "2.0.0",
"@ldapjs/dn": "1.1.0",
"@ldapjs/filter": "2.1.0",
"@ldapjs/messages": "^1.2.0",
"@ldapjs/asn1": "^2.0.0",
"@ldapjs/attribute": "^1.0.0",
"@ldapjs/change": "^1.0.0",
"@ldapjs/controls": "^2.0.0",
"@ldapjs/dn": "^1.1.0",
"@ldapjs/filter": "^2.1.1",
"@ldapjs/messages": "^1.2.1",
"@ldapjs/protocol": "^1.2.1",
"abstract-logging": "^2.0.1",
"assert-plus": "^1.0.0",
Expand Down
71 changes: 59 additions & 12 deletions test-integration/client/issue-860.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,33 @@ const baseURL = `${SCHEME}://${HOST}:${PORT}`

const client = ldapjs.createClient({ url: baseURL })

const opts = {
filter: '(&(objectClass=person))',
scope: 'sub',
paged: true,
sizeLimit: 100,
attributes: ['cn', 'employeeID']
}
tap.before(() => {
return new Promise((resolve, reject) => {
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
if (err) {
return reject(err)
}
resolve()
})
})
})

const baseDN = parseDN('ou=テスト,dc=planetexpress,dc=com')
tap.teardown(() => {
client.unbind()
})

tap.test('can search OUs with Japanese characters', t => {
client.bind('cn=admin,dc=planetexpress,dc=com', 'GoodNewsEveryone', (err) => {
t.error(err, 'bind error')
})
t.plan(2)

const opts = {
filter: '(&(objectClass=person))',
scope: 'sub',
paged: true,
sizeLimit: 100,
attributes: ['cn', 'employeeID']
}

const baseDN = parseDN('ou=テスト,dc=planetexpress,dc=com')

client.search(baseDN.toString(), opts, (err, res) => {
t.error(err, 'search error')
Expand All @@ -42,7 +55,41 @@ tap.test('can search OUs with Japanese characters', t => {
t.error(err, 'search entry error')
})
res.on('end', () => {
client.unbind(t.end)
t.end()
})
})
})

tap.test('can search with non-ascii chars in filter', t => {
t.plan(3)

const opts = {
filter: '(&(sn=Rodríguez))',
scope: 'sub',
attributes: ['dn', 'sn', 'cn'],
type: 'user'
}

let searchEntryCount = 0
client.search('dc=planetexpress,dc=com', opts, (err, res) => {
t.error(err, 'search error')
res.on('searchEntry', (entry) => {
searchEntryCount += 1
t.match(entry.pojo, {
type: 'SearchResultEntry',
objectName: 'cn=Bender Bending Rodr\\c3\\adguez,ou=people,dc=planetexpress,dc=com',
attributes: [{
type: 'cn',
values: ['Bender Bending Rodríguez']
}]
})
})
res.on('error', (err) => {
t.error(err, 'search entry error')
})
res.on('end', () => {
t.equal(searchEntryCount, 1, 'should have found 1 entry')
t.end()
})
})
})