1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
var { saslPrep } = ChromeUtils.importESModule(
"resource:///modules/xmpp-authmechs.sys.mjs"
);
// RFC 4013 3.Examples
var TEST_DATA = [
{
// SOFT HYPHEN mapped to nothing.
input: "I\u00adX",
output: "IX",
isError: false,
},
{
// No transformation.
input: "user",
output: "user",
isError: false,
},
{
// Case preserved, will not match #2.
input: "USER",
output: "USER",
isError: false,
},
{
// Output is NFKC, input in ISO 8859-1.
input: "\u00aa",
output: "a",
isError: false,
},
{
// Output is NFKC, will match #1.
input: "\u2168",
output: "IX",
isError: false,
},
{
// Error - prohibited character.
input: "\u0007",
output: "",
isError: true,
},
{
// Error - bidirectional check.
input: "\u0627\u0031",
output: "",
isError: true,
},
];
function run_test() {
for (let current of TEST_DATA) {
try {
let result = saslPrep(current.input);
equal(current.isError, false);
equal(result, current.output);
} catch (e) {
equal(current.isError, true);
}
}
run_next_test();
}
|