|
|
@@ -822,7 +822,7 @@ static const struct idna idna[] = { |
|
|
{"_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|IDN2_NO_TR46}, /* flag is ignored when not using TR46 */ |
|
|
/* _��� */ |
|
|
/* _??? */ |
|
|
{"_\xc3\xbc", "xn--_-eha", IDN2_DISALLOWED, IDN2_NO_TR46}, |
|
|
{"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_TRANSITIONAL}, |
|
|
{"_\xc3\xbc", "xn--_-eha", IDN2_OK, IDN2_NONTRANSITIONAL}, |
|
|
@@ -839,12 +839,12 @@ static const struct idna idna[] = { |
|
|
static int ok = 0, failed = 0; |
|
|
static int break_on_error = 0; |
|
|
|
|
|
static char *_nextField(char **line) |
|
|
static const char *_nextField(char **line) |
|
|
{ |
|
|
char *s = *line, *e; |
|
|
|
|
|
if (!*s) |
|
|
return NULL; |
|
|
return ""; |
|
|
|
|
|
if (!(e = strpbrk(s, ";#"))) { |
|
|
e = *line += strlen(s); |
|
|
@@ -899,7 +899,6 @@ test_homebrewed(void) |
|
|
{ |
|
|
uint32_t dummy_u32[4] = { 'a', 'b', 'c', 0 }; |
|
|
uint8_t *out; |
|
|
char outbuf[4]; |
|
|
size_t i; |
|
|
int rc; |
|
|
|
|
|
@@ -1033,17 +1032,18 @@ test_homebrewed(void) |
|
|
ok++; |
|
|
} |
|
|
|
|
|
if ((rc = idna_to_ascii_4i (dummy_u32, 4, outbuf, 0)) != IDN2_OK) { |
|
|
if ((rc = idn2_to_ascii_4i2 (dummy_u32, 4, (char **) &out, 0)) != IDN2_OK) { |
|
|
failed++; |
|
|
printf("special #9 failed with %d\n", rc); |
|
|
} else { |
|
|
idn2_free (out); |
|
|
ok++; |
|
|
} |
|
|
} |
|
|
|
|
|
// decode embedded UTF-16/32 sequences |
|
|
static char * |
|
|
_decodeIdnaTest(uint8_t *src_u8) |
|
|
static uint8_t * |
|
|
_decodeIdnaTest(const uint8_t *src_u8) |
|
|
{ |
|
|
size_t it2 = 0, len; |
|
|
uint32_t *src; |
|
|
@@ -1088,19 +1088,16 @@ _decodeIdnaTest(uint8_t *src_u8) |
|
|
} |
|
|
|
|
|
// convert UTF-32 to UTF-8 |
|
|
uint8_t *tmp=src_u8; |
|
|
src_u8 = u32_to_u8(src, it2, NULL, &len); |
|
|
free(src); |
|
|
if (!src_u8) { |
|
|
printf("u32_to_u8(%s) failed (%d)\n", tmp, errno); |
|
|
return NULL; |
|
|
} |
|
|
uint8_t *dst_u8 = u32_to_u8(src, it2, NULL, &len); |
|
|
if (!dst_u8) |
|
|
printf("u32_to_u8(%s) failed (%d)\n", src_u8, errno); |
|
|
|
|
|
return (char *) src_u8; |
|
|
free(src); |
|
|
return dst_u8; |
|
|
} |
|
|
|
|
|
static void |
|
|
_check_toASCII(char *source, char *expected, int transitional, int expected_toASCII_failure) |
|
|
_check_toASCII(const char *source, const char *expected, int transitional, int expected_toASCII_failure) |
|
|
{ |
|
|
int rc; |
|
|
char *ace = NULL; |
|
|
@@ -1133,18 +1130,19 @@ _check_toASCII(char *source, char *expected, int transitional, int expected_toAS |
|
|
static int |
|
|
test_IdnaTest(char *linep) |
|
|
{ |
|
|
char *type, *source, *toUnicode, *toASCII, *NV8, *org_source; |
|
|
char *source; |
|
|
const char *type, *toUnicode, *toASCII, *NV8, *org_source; |
|
|
int expected_toASCII_failure; |
|
|
|
|
|
type = _nextField(&linep); |
|
|
org_source = source = _nextField(&linep); |
|
|
org_source = _nextField(&linep); |
|
|
toUnicode = _nextField(&linep); |
|
|
toASCII = _nextField(&linep); |
|
|
NV8 = _nextField(&linep); // if set, the input should be disallowed for IDNA2008 |
|
|
|
|
|
// sigh, these Unicode people really mix UTF-8 and UCS-2/4 |
|
|
// quick and dirty translation of '\uXXXX' found in IdnaTest.txt including surrogate handling |
|
|
source = _decodeIdnaTest((uint8_t *) source); |
|
|
source = (char *) _decodeIdnaTest((uint8_t *) org_source); |
|
|
if (!source) |
|
|
return 0; // some Unicode sequences can't be encoded into UTF-8, skip them |
|
|
|
|
|
|