Commit 31b11be3 authored by Tim Rühsen's avatar Tim Rühsen

Fix STD3 ASCII rules

parent 65a1a979
Pipeline #17403809 passed with stages
in 14 minutes and 36 seconds
......@@ -180,7 +180,20 @@ _idn2_label_test (int what, const uint32_t * label, size_t llen)
size_t i;
for (i = 0; i < llen; i++)
if (_idn2_disallowed_p (label[i]))
return IDN2_DISALLOWED;
{
if ((what & (TEST_TRANSITIONAL | TEST_NONTRANSITIONAL)) &&
(what & TEST_ALLOW_STD3_DISALLOWED))
{
IDNAMap map;
get_idna_map (label[i], &map);
if (map_is (&map, TR46_FLG_DISALLOWED_STD3_VALID) ||
map_is (&map, TR46_FLG_DISALLOWED_STD3_MAPPED))
continue;
}
return IDN2_DISALLOWED;
}
}
if (what & TEST_CONTEXTJ)
......
......@@ -89,7 +89,10 @@ label (const uint8_t * src, size_t srclen, uint8_t * dst, size_t * dstlen,
TEST_DISALLOWED |
TEST_CONTEXTJ_RULE |
TEST_CONTEXTO_WITH_RULE |
TEST_UNASSIGNED | TEST_BIDI, p, plen);
TEST_UNASSIGNED | TEST_BIDI |
((flags & IDN2_NONTRANSITIONAL) ? TEST_NONTRANSITIONAL : 0) |
((flags & IDN2_USE_STD3_ASCII_RULES) ? 0 : TEST_ALLOW_STD3_DISALLOWED),
p, plen);
if (rc != IDN2_OK)
{
......
......@@ -814,13 +814,20 @@ static const struct idna idna[] = {
},
/* √.com */
{"\xe2\x88\x9a.com", "xn--19g.com", IDN2_OK, IDN2_TRANSITIONAL},
/* domains with non-STD3 characters (removed by default when using TR46 transitional/non-trnasitional */
/* domains with non-STD3 characters (removed by default when using TR46 transitional/non-transitional */
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, 0},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_TRANSITIONAL},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_NONTRANSITIONAL},
{"_443._tcp.example.com", "443.tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_NONTRANSITIONAL},
{"_443._tcp.example.com", "443.tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_TRANSITIONAL},
{"_443._tcp.example.com", "_443._tcp.example.com", IDN2_OK, IDN2_USE_STD3_ASCII_RULES}, /* flag is ignored when not using TR46 */
/* _ */
{"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, 0},
{"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_TRANSITIONAL},
{"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_NONTRANSITIONAL},
{"_\xc3\xbc", "xn--tda", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_NONTRANSITIONAL},
{"_\xc3\xbc", "xn--tda", IDN2_OK, IDN2_USE_STD3_ASCII_RULES|IDN2_TRANSITIONAL},
{"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, IDN2_USE_STD3_ASCII_RULES}, /* flag is ignored when not using TR46 */
};
static int ok = 0, failed = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment