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

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 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions lib/utils/escape-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ module.exports = function escapeValue (value) {

if (charHex >= 0xe0 && charHex <= 0xef) {
// Represents the first byte in a 3-byte UTF-8 character.
escaped.push(toEscapedHexString(charHex))
escaped.push(toEscapedHexString(toEscape[i + 1]))
escaped.push(toEscapedHexString(toEscape[i + 2]))
escaped.push(Buffer.from([charHex, toEscape[i + 1], toEscape[i + 2]], 'utf8').toString())
i += 3
continue
}
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/escape-value.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ tap.test('2-byte utf-8', t => {

tap.test('3-byte utf-8', t => {
t.test('₠', async t => {
t.equal(escapeValue('₠'), '\\e2\\82\\a0')
t.equal(escapeValue('₠'), '₠')
})

t.test('中文', async t => {
t.equal(escapeValue('中文'), '中文')
})

t.end()
Expand Down