diff options
author | louiz’ <louiz@louiz.org> | 2017-02-15 01:05:42 +0100 |
---|---|---|
committer | louiz’ <louiz@louiz.org> | 2017-02-15 01:07:32 +0100 |
commit | fef585ad6699042e594f407afe78df1e40344efe (patch) | |
tree | 00a4c5e388eafc8a5aa39415fb552db3c8f9f987 /tests | |
parent | 7f08cf83aa5db58bfac004dddae565e6536eeb2c (diff) | |
download | biboumi-fef585ad6699042e594f407afe78df1e40344efe.tar.gz biboumi-fef585ad6699042e594f407afe78df1e40344efe.tar.bz2 biboumi-fef585ad6699042e594f407afe78df1e40344efe.tar.xz biboumi-fef585ad6699042e594f407afe78df1e40344efe.zip |
Surround ipv6 with [], and properly cleanup otherwise invalid domains
fix #2694 (yeah, it was closed, but it was badly fixed)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/jid.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/jid.cpp b/tests/jid.cpp index 9015afd..089f797 100644 --- a/tests/jid.cpp +++ b/tests/jid.cpp @@ -15,7 +15,10 @@ TEST_CASE("Jid") CHECK(jid2.local == ""); CHECK(jid2.domain == "ツ.coucou"); CHECK(jid2.resource == "coucou@coucou/coucou"); +} +TEST_CASE("jidprep") +{ // Jidprep const std::string badjid("~zigougou™@EpiK-7D9D1FDE.poez.io/Boujour/coucou/slt™"); const std::string correctjid = jidprep(badjid); @@ -26,13 +29,18 @@ TEST_CASE("Jid") CHECK(jidprep(badjid) == "~zigougoutm@epik-7d9d1fde.poez.io/Boujour/coucou/sltTM"); CHECK(jidprep(badjid) == "~zigougoutm@epik-7d9d1fde.poez.io/Boujour/coucou/sltTM"); - const std::string badjid2("Zigougou@poez.io"); - const std::string correctjid2 = jidprep(badjid2); - CHECK(correctjid2 == "zigougou@poez.io"); + CHECK(jidprep("Zigougou@poez.io") == "zigougou@poez.io"); + + CHECK(jidprep("~Bisous@88.123.43.45") == "~bisous@88.123.43.45"); + + CHECK(jidprep("~Bisous@::ffff:42.156.139.46") == "~bisous@[::ffff:42.156.139.46]"); + + CHECK(jidprep("louiz!6bf74289@2001:bc8:38e7::") == "louiz!6bf74289@[2001:bc8:38e7::]"); - const std::string crappy("~Bisous@7ea8beb1:c5fd2849:da9a048e:ip"); - const std::string fixed_crappy = jidprep(crappy); - CHECK(fixed_crappy == "~bisous@7ea8beb1-c5fd2849-da9a048e-ip"); + CHECK(jidprep("louiz@+:::::----coucou.com78--.") == "louiz@coucou.com78"); + CHECK(jidprep("louiz@coucou.com78--.") == "louiz@coucou.com78"); + CHECK(jidprep("louiz@+:::::----coucou.com78") == "louiz@coucou.com78"); + CHECK(jidprep("louiz@:::::") == "louiz@empty"); #else // Without libidn, jidprep always returns an empty string CHECK(jidprep(badjid) == ""); #endif |