Example #1
0
static void test_dns_name_apply_idna(void) {
        test_dns_name_apply_idna_one("", "");
        test_dns_name_apply_idna_one("foo", "foo");
        test_dns_name_apply_idna_one("foo.", "foo");
        test_dns_name_apply_idna_one("foo.bar", "foo.bar");
        test_dns_name_apply_idna_one("foo.bar.", "foo.bar");
        test_dns_name_apply_idna_one("föö", "xn--f-1gaa");
        test_dns_name_apply_idna_one("föö.", "xn--f-1gaa");
        test_dns_name_apply_idna_one("föö.bär", "xn--f-1gaa.xn--br-via");
        test_dns_name_apply_idna_one("föö.bär.", "xn--f-1gaa.xn--br-via");
}
Example #2
0
static void test_dns_name_apply_idna(void) {
#if HAVE_LIBIDN2 || HAVE_LIBIDN
        const int ret = 1;
#else
        const int ret = 0;
#endif

        /* IDNA2008 forbids names with hyphens in third and fourth positions
         * (https://tools.ietf.org/html/rfc5891#section-4.2.3.1).
         * IDNA2003 does not have this restriction
         * (https://tools.ietf.org/html/rfc3490#section-5).
         * This means that when using libidn we will transform and test more
         * labels. If registrars follow IDNA2008 we'll just be performing a
         * useless lookup.
         */
#if HAVE_LIBIDN
        const int ret2 = 1;
#else
        const int ret2 = 0;
#endif

        test_dns_name_apply_idna_one("", ret, "");
        test_dns_name_apply_idna_one("foo", ret, "foo");
        test_dns_name_apply_idna_one("foo.", ret, "foo");
        test_dns_name_apply_idna_one("foo.bar", ret, "foo.bar");
        test_dns_name_apply_idna_one("foo.bar.", ret, "foo.bar");
        test_dns_name_apply_idna_one("föö", ret, "xn--f-1gaa");
        test_dns_name_apply_idna_one("föö.", ret, "xn--f-1gaa");
        test_dns_name_apply_idna_one("föö.bär", ret, "xn--f-1gaa.xn--br-via");
        test_dns_name_apply_idna_one("föö.bär.", ret, "xn--f-1gaa.xn--br-via");
        test_dns_name_apply_idna_one("xn--f-1gaa.xn--br-via", ret, "xn--f-1gaa.xn--br-via");

        test_dns_name_apply_idna_one("_443._tcp.fedoraproject.org", ret2,
                                     "_443._tcp.fedoraproject.org");
        test_dns_name_apply_idna_one("_443", ret2, "_443");
        test_dns_name_apply_idna_one("gateway", ret, "gateway");
        test_dns_name_apply_idna_one("_gateway", ret2, "_gateway");

        test_dns_name_apply_idna_one("r3---sn-ab5l6ne7.googlevideo.com", ret2,
                                     ret2 ? "r3---sn-ab5l6ne7.googlevideo.com" : "");
}