Software /
code /
prosody
Annotate
tests/test_sasl.lua @ 7567:495de404a8ae
ejabberdsql2prosody: rename variable 'host' to prevent shadowing upvalue [luacheck]
Functions roster(), roster_pending(), roster_group(), private_storage() and
offline_msg() have argument named "host", which used to shadow upvalue of this
variable before this change. Instead of renaming this argument, let's rename
the variable to match what the script says in usage:
Usage: ejabberdsql2prosody.lua filename.txt hostname
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 12 Aug 2016 13:44:47 +0800 |
parent | 5776:bd0ff8ae98a8 |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
1 -- Prosody IM |
2923
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
b7049746bd29
Update copyright headers for 2010
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4163
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
509
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
509
diff
changeset
|
8 |
3540
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
9 local gmatch = string.gmatch; |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
10 local t_concat, t_insert = table.concat, table.insert; |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
11 local to_byte, to_char = string.byte, string.char; |
509
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 local function _latin1toutf8(str) |
3540
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
14 if not str then return str; end |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
15 local p = {}; |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
16 for ch in gmatch(str, ".") do |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
17 ch = to_byte(ch); |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
18 if (ch < 0x80) then |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
19 t_insert(p, to_char(ch)); |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
20 elseif (ch < 0xC0) then |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
21 t_insert(p, to_char(0xC2, ch)); |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
22 else |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
23 t_insert(p, to_char(0xC3, ch - 64)); |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
24 end |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
25 end |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
26 return t_concat(p); |
bc139431830b
Monster whitespace commit (beware the whitespace monster).
Waqas Hussain <waqas20@gmail.com>
parents:
2923
diff
changeset
|
27 end |
509
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 function latin1toutf8() |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 local function assert_utf8(latin, utf8) |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 assert_equal(_latin1toutf8(latin), utf8, "Incorrect UTF8 from Latin1: "..tostring(latin)); |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 end |
5776
bd0ff8ae98a8
Remove all trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents:
4163
diff
changeset
|
33 |
509
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 assert_utf8("", "") |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 assert_utf8("test", "test") |
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 assert_utf8(nil, nil) |
4163
bbfbdbc5e77e
tests/test_sasl.lua: Convert literal UTF-8/Latin1 chars to escape codes for weak text editors
Matthew Wild <mwild1@gmail.com>
parents:
3540
diff
changeset
|
37 assert_utf8("foobar.r\229kat.se", "foobar.r\195\165kat.se") |
509
32899c8a6fe5
Add test for latin1toutf8 (which passes)
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 end |