diff options
author | Andrew Lewis <nerf@judo.za.org> | 2020-12-09 11:11:54 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2020-12-09 11:11:54 +0200 |
commit | bbd94b406197e04387e600a82d38b310e76ec464 (patch) | |
tree | 36ce3a51d53954a40bbbdbb86edf0afa3ce580fc /test | |
parent | fe6e15ef22fbdd698d918413bcba382471a8aba3 (diff) | |
download | rspamd-bbd94b406197e04387e600a82d38b310e76ec464.tar.gz rspamd-bbd94b406197e04387e600a82d38b310e76ec464.zip |
[Test] Add some unit tests for punycode conversion
Diffstat (limited to 'test')
-rw-r--r-- | test/lua/unit/rspamd_resolver.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/lua/unit/rspamd_resolver.lua b/test/lua/unit/rspamd_resolver.lua new file mode 100644 index 000000000..e987ff00b --- /dev/null +++ b/test/lua/unit/rspamd_resolver.lua @@ -0,0 +1,31 @@ +-- Rspamd resolver Lua tests + +context("Check punycoding UTF-8 URL", function() + local rspamd_resolver = require "rspamd_resolver" + local rspamd_util = require "rspamd_util" + + local resolver = rspamd_resolver.init(rspamd_util.create_event_base(), rspamd_config) + + local cases = { + -- https://unicode.org/reports/tr46/#Deviations + ['faß.de'] = 'fass.de', -- IDNA2008 result: xn--fa-hia.de + ['βόλος.com'] = 'xn--nxasmq6b.com', -- IDNA2008 result: xn--nxasmm1c.com + ['نامهای.com'] = 'xn--mgba3gch31f.com', -- IDNA2008 result: xn--mgba3gch31f060k.com + ['ශ්රී.com'] = 'xn--10cl1a0b.com', -- IDNA2008 result: xn--10cl1a0b660p.com + + -- https://unicode.org/reports/tr46/#Table_Example_Processing + ['日本語。JP'] = 'xn--wgv71a119e.jp', -- Fullwidth characters are remapped, including 。 + --['u¨.com'] = 'xn--tda.com', -- Normalize changes u + umlaut to ü + ['☕.us'] = 'xn--53h.us', -- Post-Unicode 3.2 characters are allowed + + -- Other + ['example.рф'] = 'example.xn--p1ai', + } + + for k, v in pairs(cases) do + test(string.format("punycode %s -> %s", k, v), function() + local res = resolver:idna_convert_utf8(k) + assert_equal(res, v) + end) + end +end) |