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

Commit ba2e8c4

Browse files
author
丁言河D0362319
committed
fix: a 3-byte UTF-8 character don't convert to hex string,ldap server can support \u or \U, but it is'n support hex string
1 parent 7aa09bc commit ba2e8c4

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/utils/escape-value.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ module.exports = function escapeValue (value) {
5858

5959
if (charHex >= 0xe0 && charHex <= 0xef) {
6060
// Represents the first byte in a 3-byte UTF-8 character.
61-
escaped.push(toEscapedHexString(charHex))
62-
escaped.push(toEscapedHexString(toEscape[i + 1]))
63-
escaped.push(toEscapedHexString(toEscape[i + 2]))
61+
escaped.push(Buffer.from([charHex, toEscape[i + 1], toEscape[i + 2]], 'utf8').toString())
6462
i += 3
6563
continue
6664
}

lib/utils/escape-value.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ tap.test('2-byte utf-8', t => {
4747

4848
tap.test('3-byte utf-8', t => {
4949
t.test('₠', async t => {
50-
t.equal(escapeValue('₠'), '\\e2\\82\\a0')
50+
t.equal(escapeValue('₠'), '₠')
51+
})
52+
53+
t.test('中文', async t => {
54+
t.equal(escapeValue('中文'), '中文')
5155
})
5256

5357
t.end()

0 commit comments

Comments
 (0)