-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle utf8 encoded string from ldap
- Loading branch information
Showing
6 changed files
with
101 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const { exportForTesting } = require('../index.js') | ||
const { _isHex, _parseEscapedHexToUtf8, _recursiveParseHexString } = | ||
exportForTesting | ||
|
||
describe('string conversion test', () => { | ||
it('unescape string test', () => { | ||
let s = | ||
'cn=\\e7\\a0\\94\\e5\\8f\\91A\\e9\\83\\a8,ou=users,dc=example,dc=com' | ||
let us = _parseEscapedHexToUtf8(s) | ||
expect(us).toEqual('cn=研发A部,ou=users,dc=example,dc=com') | ||
}) | ||
it('unescape string test2', () => { | ||
let s = | ||
'cn=\\e7\\a0\\94\\e5\\8f\\91A\\e9\\83\\a8\\c2\\a9,ou=users,dc=example,dc=com' | ||
let us = _parseEscapedHexToUtf8(s) | ||
expect(us).toEqual('cn=研发A部©,ou=users,dc=example,dc=com') | ||
}) | ||
it('unescape string test3', () => { | ||
let s = 'cn=ABC,ou=users,dc=example,dc=com' | ||
let us = _parseEscapedHexToUtf8(s) | ||
expect(us).toEqual('cn=ABC,ou=users,dc=example,dc=com') | ||
}) | ||
it('convert obj', () => { | ||
let target = { | ||
a: ['研发A部©', 'abc'], | ||
b: 'xyz', | ||
c: true, | ||
d: null, | ||
e: '研发A部©', | ||
f: 1000, | ||
} | ||
let obj = { | ||
a: ['\\e7\\a0\\94\\e5\\8f\\91A\\e9\\83\\a8\\c2\\a9', 'abc'], | ||
b: 'xyz', | ||
c: true, | ||
d: null, | ||
e: '\\e7\\a0\\94\\e5\\8f\\91A\\e9\\83\\a8\\c2\\a9', | ||
f: 1000, | ||
} | ||
let converted = _recursiveParseHexString(obj) | ||
expect(converted).toEqual(target) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters