@@ -0,0 +1 @@
n--ßH
@@ -0,0 +1,3 @@
!ŀ̀dict=li`.3َ̀dict=li`.3َ̀̀+=̀=
=
َ)َ)ǎ.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
@@ -0,0 +1 @@
125fIcE.xn‍--w.XN--w127f.xn--w125f.x.XN--1;XN--w063f.xn‍-N--w126f.xn‍--w'106f

This file was deleted.

Binary file not shown.
@@ -0,0 +1 @@
XN---ßT.xn&--x

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
͵8͵..);)ٵ..)ݮٵ)ٵ..)ݮ..

This file was deleted.

@@ -0,0 +1 @@
۲۰.xn--%)))).
@@ -0,0 +1 @@
xn--.۲.۲.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
 -n ١:
@@ -0,0 +1 @@
Xxn%%%%%%-%%%%@%%%%%%%%%%XN--%%%%%%%%%%%%%%%%XN--%%%%%%%%%%%%%-ß
@@ -0,0 +1 @@
--ß

This file was deleted.

@@ -0,0 +1 @@
X-N-)-mYYß.xn--9999999rzr99XN-)--mYYß.xn--;9999rrrzrrrr9998r
@@ -0,0 +1 @@
,xn6ß6
@@ -0,0 +1 @@
xn--n-MMMxn--MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMEMMMMMMMMMMMMMP,
@@ -0,0 +1 @@
;)()))))۰.)٦.

This file was deleted.

@@ -0,0 +1 @@
XN--.׳..׳.
@@ -0,0 +1 @@
?XN--??????????????????????????????????????????????????????????????????;.۷۷.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
‍)XN--)Z;^Z6ZX;-xZxn--ZZZZZXr~r~
@@ -0,0 +1 @@
.XN--;ގَ,
@@ -0,0 +1 @@
)ٵ.ٵݮ..)ٵ)...)ݮ۵..))ٵ..)ݮ..)ٵ)...)ݮٵ..))ٵ..)ݮ.۵.ٵݮ..)ٵ)...)ݮٵ..).)۵.ٵݮ..)ٵ)...)ݮٵ..))ٵ..)ݮ..)ٵ)...)ݮٵ..))ٵ..)

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
)))))XN--)٦.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
XN--xn--ßT.xn----

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
xn--XN--ß5
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
!ͧ=‍
@@ -0,0 +1 @@
ݐ‌ݐ!‌x

This file was deleted.

@@ -0,0 +1 @@
XN--NXkNß
@@ -0,0 +1,2 @@
!XN--ŀ=
=J
@@ -0,0 +1 @@
.xn--0099000a099000a999a9000a09,xN--ß-99999a90000
@@ -0,0 +1 @@
"xn-ݐ ݐ-,¨‌x,
@@ -0,0 +1 @@
!XN--.ٮ2.ٮ2
Binary file not shown.
@@ -0,0 +1 @@
xn--ßhxn---0000F-9999F

This file was deleted.

Binary file not shown.
@@ -0,0 +1,3 @@
!ŀ̀dict=li`.3َ̀̀2
=
َ)َ)ǎ.
Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
ßß.xn--A19541r.xn--Aßu&.x
Binary file not shown.
@@ -0,0 +1 @@
.Х.3.َ.Х.3.ََ)َََ)َ)Х.3.ََ)َ).3.َ.Х.3.ََ)َXN--)Х.3.ََ)َ)ََ.َ)ََ.)Х.)Х.3.ََ)َ)ََ.َ.Х.3.ََ)َ)Х.3.ََ)َ)ََ.3.َ.Х.3.ََ)َ)Х.3.ََ)َ)ََ.َ)ََ.)Х.3ََ.َ)ََ.)Х.3.ََ)َ).َ)ََ.

This file was deleted.

Binary file not shown.
@@ -0,0 +1 @@
۰۰.۰)))))))۰.|n--)٦ۦ.

This file was deleted.

@@ -0,0 +1 @@
ﵿ⵿「x
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
9⵿‍⵿‍9⵿‍⵿‍9⵿‍9⵿‍⵿‍9⵿‍⵿‍9⵿‍⵿‍9⵿‍⵿‍9⵿‍9⵿‍⵿‍9⵿‍⵿‍0⵿‍9⵿‍9⵿‍⵿‍9⵿‍9⵿‍⵿‍⵿‍9⵿‍⵿‍9⵿‍9⿀(ⵍ⵿‍⵿‍

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
XN--..٣w
@@ -0,0 +1 @@
XN--467$dflllllllll;lllllllllllllllll01‌\3X

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
‌xn--ﷺn--ﷺ
@@ -0,0 +1 @@
ݐ‌ݐ ‌mm--'ٮ.XN-X-m٥..ݮ.3ِ.)ٮ*.!ǎِ).ݮ.3ِ.)ٮ*.ǎِ).ݮ.3ِ.)ٮ*.!ǎِ)ٮ*.ǎِ).ݮ.3ِ.)ǎِ)&ݮ.3ِ.)֮Xmm--'ٮ.XN-X-m.ݮ.3ِ0.)ٮ*.!ǎِ).ݮ.3ِ0.)ٮ*.!ǎِ).ݮ.3ِ.)ٮ*.ǎِ).ݮ.3ِ.)ٮ*.!ǎِ)
@@ -0,0 +1 @@
XN---ßT.XN---(
Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
)XN--・ݮ

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
)͵3.)N--ݮٵ..))ٵ).͵3.)N

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
nX--٠
@@ -0,0 +1 @@
XN--8Y9^9YY
@@ -0,0 +1 @@
))-٢.

This file was deleted.

@@ -0,0 +1 @@
XN--‌.
Binary file not shown.
@@ -0,0 +1 @@
;ٮ2.ٮ2
@@ -0,0 +1 @@
‍9XN--)Z;^Z6ZX;-xZxn--ZZZZZXr~r~

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
!xn--XN--xn--w(wvvxn--w(wvXN---ßT.xn&v--vxN
Binary file not shown.
@@ -0,0 +1 @@
‌x:--ﷺﷺ-
@@ -0,0 +1 @@
΅΅΅΅΅΅΅΅-.υ΅΅΅΅΅xn΅΅΅΅΅΅΅΅΅΅΅t-΅΅-΅2t΅΅΅΅΅΅΅-t΅΅.X
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
‍)XN--)Z;^Z[ZZZZZXr~r~
@@ -0,0 +1 @@
.۴۴.....۴۴۴....۴۴۴.۶۴۴....۴۴.۴.۴۴۴۴.XN--:.۴.
@@ -0,0 +1 @@
XN---ßT.xn---x
@@ -0,0 +1 @@
XN--IN\g.XN--N-Nß
Binary file not shown.
@@ -0,0 +1 @@
ς‌̀

This file was deleted.

@@ -0,0 +1 @@
xn(--9RDJ0C9RJ99H
@@ -0,0 +1 @@
xn---ßT.xn---}-

This file was deleted.

Binary file not shown.
@@ -0,0 +1 @@
xn--.٤٤

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
)ٮ.XXXjobsXXXXXXXXXXXN--XXXXXXXXXXXXXXXXXXXXN--XXXXXXXXXXXXXXXx-‌XXX:XXXXXXXX

This file was deleted.

@@ -0,0 +1 @@
..XN---m..
@@ -0,0 +1 @@
!--۷.

This file was deleted.

@@ -0,0 +1 @@
 xn--.١:
@@ -0,0 +1 @@
,xN--ßccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc-
Binary file not shown.
@@ -0,0 +1 @@
XN--ß-*-
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
5r.xn--A19542r.xn--Aßu&&.xn--A195XN--x
@@ -0,0 +1 @@
ß--㎯
@@ -0,0 +1 @@
XN/‍
Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
X*‌.xn--1111XN--11111
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
 xn--.١١
Binary file not shown.
@@ -0,0 +1 @@
125f.x.XN--w126f.xn--w125f.x.XN--w!26f.f.xn--w125f.x.XN--w!26f.xn--w126f.Vn.XN--w126f.xn‍--w'126f

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
.٨..ݮ.3ِ.)ٮ*.!ǎِ).ݮ.3ِ.)ٮ*.ǎِ).ݮ.3ِ.)ٮ*.!ǎِ)ٮ*.ǎِ).ݮ.6ِ*)ǎِ).ݮ.3ِ.)ٮ*ٮ*.ǎِ)ǎ,ǎ)ٮ*.ǎِ)ǎ,).ݮ.3ِ.)ٮ*.ǎِ)ǎ).ݮ.6ِ.)ٮ*.ǎِ).ݮ.3ِ.)ٮ*.!ǎِ)ٮ*.ǎِ).ݮ.3ِ.)ǎِ).ݮ.3ِ.)ٮ*ٮ*.ǎِ)ǎ,ǎ,ٮ*.!ǎِ).ݮ.3ِ.)ٮ*.ǎِ)ǎ,).ݮ.3,ǎ,
@@ -0,0 +1 @@
‍)XN--)X;^XN--ZZXr~r~
Binary file not shown.
@@ -0,0 +1 @@
'۸.۸.۲n.XN--
@@ -0,0 +1 @@
ݐ:‌ݐ!‌x

This file was deleted.

@@ -0,0 +1 @@
)xn--..)xn-۶n-۶۶۶۶۶۶wxn--www.۶۶-۶n۷۶۶۶wwwx)n-۶۵..))ٵ..)ݮ...wwwww

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
XN--..ѣ-)-!٣٣w
Binary file not shown.
@@ -0,0 +1 @@
)ٵ.ٵݮ..)ٵ)...)ݮٵ..))ٵ..)ݮ...)ݮٵ..))ٵ..)ݮ..)۵.ٵݮ..)ٵ)...)ݮٵ..))ٵ..)ݮ..)ٵ)...)ݮٵ..))ٵ..)
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
)ݮ.)・ݮ
@@ -0,0 +1 @@
XN---‷‌x)‷‌--‗‷-‷‷XN---
@@ -0,0 +1 @@
n-x-ßh.xn--999'h.xn-F
Binary file not shown.
@@ -0,0 +1 @@
xnT.xn----ßT.xn---}-
Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -0,0 +1 @@
xn--ß--xx-.xn#-n-MMMxn--MMMMMMMMMMMMMMMMMMP,XN--
@@ -0,0 +1 @@
!XN--.ٮ2.!XN

This file was deleted.

This file was deleted.

Binary file not shown.
@@ -32,10 +32,13 @@
#include "idn2.h"
#include "fuzzer.h"

#pragma GCC optimize ("O0")

int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
char *domain;
char *out;
const char *x = "";

if (size > 1024)
return 0;
@@ -47,8 +50,61 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
memcpy(domain, data, size);
domain[size] = 0;

if (size == 0) {
x = idn2_check_version(NULL);

for (int err = -500; err <= 0; err++) {
if (idn2_strerror_name(err))
x = NULL;
if (idn2_strerror(err))
x = NULL;
}

/*** test NULL input/output combinations ***/

if (idn2_to_unicode_lzlz(NULL, &out, 0) == IDN2_OK)
idn2_free(out);
idn2_to_unicode_lzlz(NULL, NULL, 0);
idn2_to_unicode_lzlz(domain, NULL, 0);

{
uint32_t *in32 = (uint32_t *) malloc(4);
uint32_t *out32;
in32[0] = 0;
if (idn2_to_unicode_4z4z(NULL, &out32, 0) == IDN2_OK)
idn2_free(out32);
idn2_to_unicode_4z4z(NULL, NULL, 0);
idn2_to_unicode_4z4z(in32, NULL, 0);
free(in32);
}

{
uint32_t *out32;
if (idn2_to_unicode_8z4z(NULL, &out32, 0) == IDN2_OK)
idn2_free(out32);
idn2_to_unicode_8z4z(NULL, NULL, 0);
idn2_to_unicode_8z4z(domain, NULL, 0);
}

{
uint32_t *u32 = (uint32_t *) malloc(0);
size_t u32len = 0;
idn2_to_unicode_44i(NULL, 1, u32, &u32len, 0);
u32len = 0;
idn2_to_unicode_44i(NULL, 0, NULL, &u32len, 0);
free(u32);
}
}

// let's fuzz gnulib's strverscmp()
if (idn2_check_version(domain))
x = NULL;

if (x)
free(malloc(1)); // prevent compiler from optimizing out idn2_check_version()

// internally calls idn2_to_unicode_8zlz(), idn2_to_unicode_8z8z(), idn2_to_unicode_8z4z()
if (idn2_to_unicode_lzlz(domain, &out, 0) == IDNA_SUCCESS)
if (idn2_to_unicode_lzlz(domain, &out, 0) == IDN2_OK)
idn2_free(out);

if ((size & 3) == 0) {

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

@@ -0,0 +1 @@
YYYY3YYYY'Y.'*YYYYYYYYYY.'*YYYYYYYYYY.(YY(YYYYYYYY.YYYY3YYYYY.(YY(Y'YYYY+Y.'*YYYYYYYYYY.(YY(YMYYYYYY.(YY(YYYYYYYY.YYYY3YYYYY).'YYY#YYYY'Y.'*YYYYYYYYYY.(YY(Y'YYYY+Y.'*YYYYYYYYYY.(YY(YYYYYYYY.4YMMMMMMMMYY
Binary file not shown.

This file was deleted.

@@ -0,0 +1,2 @@

....((
Binary file not shown.
@@ -0,0 +1,3 @@

.((
.((

This file was deleted.

@@ -0,0 +1,2 @@

.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(.(
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,34 @@

.((
(

.(
.((
.(
.8(
.(.((((((((
.(
.((
.(
.8(
.(
.((
.(
.8(

(

.(
.((
.(
.8(
.(.((((((((
.(
.((
.(
.8(
.(
.((
.(
.8(
.(.(((((.(.(((((

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Empty file.
@@ -43,13 +43,18 @@ static void test_all_from(const char *dirname)
{
DIR *dirp;
struct dirent *dp;
char fname[1024];
int len;

if ((dirp = opendir(dirname))) {
while ((dp = readdir(dirp))) {
if (*dp->d_name == '.') continue;

char fname[strlen(dirname) + strlen(dp->d_name) + 2];
snprintf(fname, sizeof(fname), "%s/%s", dirname, dp->d_name);
len = snprintf(fname, sizeof(fname), "%s/%s", dirname, dp->d_name);
if (len < 0 || len >= (int) sizeof(fname)) {
fprintf(stderr, "File name truncation: %s/%s\n", dirname, dp->d_name);
continue;
}

int fd;
if ((fd = open(fname, O_RDONLY)) == -1) {
@@ -81,24 +86,31 @@ static void test_all_from(const char *dirname)

int main(int argc, char **argv)
{
int len;

/* if VALGRIND testing is enabled, we have to call ourselves with valgrind checking */
if (argc == 1) {
const char *valgrind = getenv("TESTS_VALGRIND");

if (valgrind && *valgrind) {
size_t cmdsize = strlen(valgrind) + strlen(argv[0]) + 32;
char *cmd = alloca(cmdsize);
char cmd[1024]; /* avoid alloca / VLA / heap allocation */

len = snprintf(cmd, sizeof(cmd), "TESTS_VALGRIND="" %s %s", valgrind, argv[0]);
if (len < 0 || len >= (int) sizeof(cmd))
return 1; /* failure on command truncation */

snprintf(cmd, cmdsize, "TESTS_VALGRIND="" %s %s", valgrind, argv[0]);
return system(cmd) != 0;
}
}

const char *target = strrchr(argv[0], '/');
target = target ? target + 1 : argv[0];

char corporadir[sizeof(SRCDIR) + 1 + strlen(target) + 8];
snprintf(corporadir, sizeof(corporadir), SRCDIR "/%s.in", target);
char corporadir[1024]; /* avoid alloca / VLA / heap allocation */

len = snprintf(corporadir, sizeof(corporadir), SRCDIR "/%s.in", target);
if (len < 0 || len >= (int) sizeof(corporadir))
return 1; /* failure on file name truncation */

test_all_from(corporadir);

@@ -40,7 +40,7 @@ workers=$(($(nproc) - 1))
jobs=$workers

clang-6.0 \
$CFLAGS -Og -g -I../include -I.. \
$CFLAGS -Og -g -I../lib -I.. \
${fuzzer}.c -o ${fuzzer} \
-Wl,-Bstatic ../lib/.libs/libidn2.a -lFuzzer \
-lunistring \
@@ -101,5 +101,5 @@ $(NFCQC):
if HAVE_LD_VERSION_SCRIPT
libidn2_la_LDFLAGS += -Wl,--version-script=$(srcdir)/idn2.map
else
libidn2_la_LDFLAGS += -export-symbols-regex '^idn2_.*|_idn2_punycode_..code'
libidn2_la_LDFLAGS += -export-symbols-regex '^idn2_.*'
endif
@@ -26,6 +26,13 @@
not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIBIDN2_BIDI_H
#define LIBIDN2_BIDI_H

#include <stdint.h>
#include "idn2.h"

int G_GNUC_IDN2_ATTRIBUTE_PURE
_idn2_bidi (const uint32_t * label, size_t llen);

int _idn2_bidi (const uint32_t * label, size_t llen) _GL_ATTRIBUTE_PURE;
#endif /* LIBIDN2_BIDI_H */
@@ -29,11 +29,8 @@
#include <config.h>

#include "idn2.h"

#include "tables.h"

#include <unictype.h> /* uc_combining_class, UC_CCC_VR */

#include "context.h"

int
@@ -115,6 +112,17 @@ _idn2_contextj_rule (const uint32_t * label, size_t llen, size_t pos)
return IDN2_CONTEXTJ_NO_RULE;
}

static const char *
_uc_script_name (ucs4_t uc)
{
const uc_script_t *ucs = uc_script(uc);

if (!ucs)
return "";

return ucs->name;
}

int
_idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos)
{
@@ -140,7 +148,7 @@ _idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos)
/* GREEK LOWER NUMERAL SIGN (KERAIA) */
if (pos == llen - 1)
return IDN2_CONTEXTO;
if (strcmp (uc_script (label[pos + 1])->name, "Greek") == 0)
if (strcmp (_uc_script_name (label[pos + 1]), "Greek") == 0)
return IDN2_OK;
return IDN2_CONTEXTO;
break;
@@ -151,7 +159,7 @@ _idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos)
/* HEBREW PUNCTUATION GERSHAYIM */
if (pos == 0)
return IDN2_CONTEXTO;
if (strcmp (uc_script (label[pos - 1])->name, "Hebrew") == 0)
if (strcmp (_uc_script_name (label[pos - 1]), "Hebrew") == 0)
return IDN2_OK;
return IDN2_CONTEXTO;
break;
@@ -202,9 +210,9 @@ _idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos)
bool script_ok = false;

for (i = 0; !script_ok && i < llen; i++)
if (strcmp (uc_script (label[i])->name, "Hiragana") == 0
|| strcmp (uc_script (label[i])->name, "Katakana") == 0
|| strcmp (uc_script (label[i])->name, "Han") == 0)
if (strcmp (_uc_script_name (label[i]), "Hiragana") == 0
|| strcmp (_uc_script_name (label[i]), "Katakana") == 0
|| strcmp (_uc_script_name (label[i]), "Han") == 0)
script_ok = true;

if (script_ok)
@@ -26,11 +26,20 @@
not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIBIDN2_CONTEXT_H
#define LIBIDN2_CONTEXT_H

#include <stdint.h>
#include <stdbool.h>
#include "idn2.h"

int G_GNUC_IDN2_ATTRIBUTE_PURE
_idn2_contextj_rule (const uint32_t * label, size_t llen, size_t pos);

int _idn2_contextj_rule (const uint32_t * label, size_t llen, size_t pos) _GL_ATTRIBUTE_PURE;
int G_GNUC_IDN2_ATTRIBUTE_PURE
_idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos);

int _idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos) _GL_ATTRIBUTE_PURE;
bool G_GNUC_IDN2_ATTRIBUTE_CONST
_idn2_contexto_with_rule (uint32_t cp);

bool _idn2_contexto_with_rule (uint32_t cp) _GL_ATTRIBUTE_CONST;
#endif /* LIBIDN2_CONTEXT_H */
@@ -26,6 +26,9 @@
not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIBIDN2_DATA_H
#define LIBIDN2_DATA_H

#include <stdint.h>
#include <sys/types.h>

@@ -43,3 +46,5 @@ struct idna_table

extern const struct idna_table idna_table[];
extern const size_t idna_table_size;

#endif /* LIBIDN2_DATA_H */
@@ -46,114 +46,39 @@
const char *
idn2_strerror (int rc)
{
const char *p;

bindtextdomain (PACKAGE, LOCALEDIR);

switch (rc)
{
case IDN2_OK:
p = _("success");
break;

case IDN2_MALLOC:
p = _("out of memory");
break;

case IDN2_NO_CODESET:
p = _("could not determine locale encoding format");
break;

case IDN2_ICONV_FAIL:
p = _("could not convert string to UTF-8");
break;

case IDN2_ENCODING_ERROR:
p = _("string encoding error");
break;

case IDN2_NFC:
p = _("string could not be NFC normalized");
break;

case IDN2_PUNYCODE_BAD_INPUT:
p = _("string contains invalid punycode data");
break;

case IDN2_PUNYCODE_BIG_OUTPUT:
p = _("punycode encoded data will be too large");
break;

case IDN2_PUNYCODE_OVERFLOW:
p = _("punycode conversion resulted in overflow");
break;

case IDN2_TOO_BIG_DOMAIN:
p = _("domain name longer than 255 characters");
break;

case IDN2_TOO_BIG_LABEL:
p = _("domain label longer than 63 characters");
break;

case IDN2_INVALID_ALABEL:
p = _("input A-label is not valid");
break;

case IDN2_UALABEL_MISMATCH:
p = _("input A-label and U-label does not match");
break;

case IDN2_NOT_NFC:
p = _("string is not in Unicode NFC format");
break;

case IDN2_2HYPHEN:
p = _("string contains forbidden two hyphens pattern");
break;

case IDN2_HYPHEN_STARTEND:
p = _("string start/ends with forbidden hyphen");
break;

case IDN2_LEADING_COMBINING:
p = _("string contains a forbidden leading combining character");
break;

case IDN2_DISALLOWED:
p = _("string contains a disallowed character");
break;

case IDN2_CONTEXTJ:
p = _("string contains a forbidden context-j character");
break;

case IDN2_CONTEXTJ_NO_RULE:
p = _("string contains a context-j character with null rule");
break;

case IDN2_CONTEXTO:
p = _("string contains a forbidden context-o character");
break;

case IDN2_CONTEXTO_NO_RULE:
p = _("string contains a context-o character with null rule");
break;

case IDN2_UNASSIGNED:
p = _("string contains unassigned code point");
break;

case IDN2_BIDI:
p = _("string has forbidden bi-directional properties");
break;

default:
p = _("Unknown error");
break;
case IDN2_OK: return _("success");
case IDN2_MALLOC: return _("out of memory");
case IDN2_NO_CODESET: return _("could not determine locale encoding format");
case IDN2_ICONV_FAIL: return _("could not convert string to UTF-8");
case IDN2_ENCODING_ERROR: return _("string encoding error");
case IDN2_NFC: return _("string could not be NFC normalized");
case IDN2_PUNYCODE_BAD_INPUT: return _("string contains invalid punycode data");
case IDN2_PUNYCODE_BIG_OUTPUT: return _("punycode encoded data will be too large");
case IDN2_PUNYCODE_OVERFLOW: return _("punycode conversion resulted in overflow");
case IDN2_TOO_BIG_DOMAIN: return _("domain name longer than 255 characters");
case IDN2_TOO_BIG_LABEL: return _("domain label longer than 63 characters");
case IDN2_INVALID_ALABEL: return _("input A-label is not valid");
case IDN2_UALABEL_MISMATCH: return _("input A-label and U-label does not match");
case IDN2_NOT_NFC: return _("string is not in Unicode NFC format");
case IDN2_2HYPHEN: return _("string contains forbidden two hyphens pattern");
case IDN2_HYPHEN_STARTEND: return _("string start/ends with forbidden hyphen");
case IDN2_LEADING_COMBINING: return _("string contains a forbidden leading combining character");
case IDN2_DISALLOWED: return _("string contains a disallowed character");
case IDN2_CONTEXTJ: return _("string contains a forbidden context-j character");
case IDN2_CONTEXTJ_NO_RULE: return _("string contains a context-j character with null rule");
case IDN2_CONTEXTO: return _("string contains a forbidden context-o character");
case IDN2_CONTEXTO_NO_RULE: return _("string contains a context-o character with null rule");
case IDN2_UNASSIGNED: return _("string contains unassigned code point");
case IDN2_BIDI: return _("string has forbidden bi-directional properties");
case IDN2_DOT_IN_LABEL: return _("domain label has forbidden dot (TR46)");
case IDN2_INVALID_TRANSITIONAL: return _("domain label has character forbidden in transitional mode (TR46)");
case IDN2_INVALID_NONTRANSITIONAL: return _("domain label has character forbidden in non-transitional mode (TR46)");
default: return _("Unknown error");
}

return p;
}

#define ERR2STR(name) #name
@@ -174,126 +99,36 @@ idn2_strerror (int rc)
const char *
idn2_strerror_name (int rc)
{
const char *p;

switch (rc)
{
case IDN2_OK:
p = ERR2STR (IDN2_OK);
break;

case IDN2_MALLOC:
p = ERR2STR (IDN2_MALLOC);
break;

case IDN2_NO_CODESET:
p = ERR2STR (IDN2_NO_NODESET);
break;

case IDN2_ICONV_FAIL:
p = ERR2STR (IDN2_ICONV_FAIL);
break;

case IDN2_ENCODING_ERROR:
p = ERR2STR (IDN2_ENCODING_ERROR);
break;

case IDN2_NFC:
p = ERR2STR (IDN2_NFC);
break;

case IDN2_PUNYCODE_BAD_INPUT:
p = ERR2STR (IDN2_PUNYCODE_BAD_INPUT);
break;

case IDN2_PUNYCODE_BIG_OUTPUT:
p = ERR2STR (IDN2_PUNYCODE_BIG_OUTPUT);
break;

case IDN2_PUNYCODE_OVERFLOW:
p = ERR2STR (IDN2_PUNYCODE_OVERFLOW);
break;

case IDN2_TOO_BIG_DOMAIN:
p = ERR2STR (IDN2_TOO_BIG_DOMAIN);
break;

case IDN2_TOO_BIG_LABEL:
p = ERR2STR (IDN2_TOO_BIG_LABEL);
break;

case IDN2_INVALID_ALABEL:
p = ERR2STR (IDN2_INVALID_ALABEL);
break;

case IDN2_UALABEL_MISMATCH:
p = ERR2STR (IDN2_UALABEL_MISMATCH);
break;

case IDN2_INVALID_FLAGS:
p = ERR2STR (IDN2_INVALID_FLAGS);
break;

case IDN2_NOT_NFC:
p = ERR2STR (IDN2_NOT_NFC);
break;

case IDN2_2HYPHEN:
p = ERR2STR (IDN2_2HYPHEN);
break;

case IDN2_HYPHEN_STARTEND:
p = ERR2STR (IDN2_HYPHEN_STARTEND);
break;

case IDN2_LEADING_COMBINING:
p = ERR2STR (IDN2_LEADING_COMBINING);
break;

case IDN2_DISALLOWED:
p = ERR2STR (IDN2_DISALLOWED);
break;

case IDN2_CONTEXTJ:
p = ERR2STR (IDN2_CONTEXTJ);
break;

case IDN2_CONTEXTJ_NO_RULE:
p = ERR2STR (IDN2_CONTEXTJ_NO_RULE);
break;

case IDN2_CONTEXTO:
p = ERR2STR (IDN2_CONTEXTO);
break;

case IDN2_CONTEXTO_NO_RULE:
p = ERR2STR (IDN2_CONTEXTO_NO_RULE);
break;

case IDN2_UNASSIGNED:
p = ERR2STR (IDN2_UNASSIGNED);
break;

case IDN2_BIDI:
p = ERR2STR (IDN2_BIDI);
break;

case IDN2_DOT_IN_LABEL:
p = ERR2STR (IDN2_DOT_IN_LABEL);
break;

case IDN2_INVALID_TRANSITIONAL:
p = ERR2STR (IDN2_INVALID_TRANSITIONAL);
break;

case IDN2_INVALID_NONTRANSITIONAL:
p = ERR2STR (IDN2_INVALID_NONTRANSITIONAL);
break;

default:
p = "IDN2_UNKNOWN";
break;
case IDN2_OK: return ERR2STR (IDN2_OK);
case IDN2_MALLOC: return ERR2STR (IDN2_MALLOC);
case IDN2_NO_CODESET: return ERR2STR (IDN2_NO_NODESET);
case IDN2_ICONV_FAIL: return ERR2STR (IDN2_ICONV_FAIL);
case IDN2_ENCODING_ERROR: return ERR2STR (IDN2_ENCODING_ERROR);
case IDN2_NFC: return ERR2STR (IDN2_NFC);
case IDN2_PUNYCODE_BAD_INPUT: return ERR2STR (IDN2_PUNYCODE_BAD_INPUT);
case IDN2_PUNYCODE_BIG_OUTPUT: return ERR2STR (IDN2_PUNYCODE_BIG_OUTPUT);
case IDN2_PUNYCODE_OVERFLOW: return ERR2STR (IDN2_PUNYCODE_OVERFLOW);
case IDN2_TOO_BIG_DOMAIN: return ERR2STR (IDN2_TOO_BIG_DOMAIN);
case IDN2_TOO_BIG_LABEL: return ERR2STR (IDN2_TOO_BIG_LABEL);
case IDN2_INVALID_ALABEL: return ERR2STR (IDN2_INVALID_ALABEL);
case IDN2_UALABEL_MISMATCH: return ERR2STR (IDN2_UALABEL_MISMATCH);
case IDN2_INVALID_FLAGS: return ERR2STR (IDN2_INVALID_FLAGS);
case IDN2_NOT_NFC: return ERR2STR (IDN2_NOT_NFC);
case IDN2_2HYPHEN: return ERR2STR (IDN2_2HYPHEN);
case IDN2_HYPHEN_STARTEND: return ERR2STR (IDN2_HYPHEN_STARTEND);
case IDN2_LEADING_COMBINING: return ERR2STR (IDN2_LEADING_COMBINING);
case IDN2_DISALLOWED: return ERR2STR (IDN2_DISALLOWED);
case IDN2_CONTEXTJ: return ERR2STR (IDN2_CONTEXTJ);
case IDN2_CONTEXTJ_NO_RULE: return ERR2STR (IDN2_CONTEXTJ_NO_RULE);
case IDN2_CONTEXTO: return ERR2STR (IDN2_CONTEXTO);
case IDN2_CONTEXTO_NO_RULE: return ERR2STR (IDN2_CONTEXTO_NO_RULE);
case IDN2_UNASSIGNED: return ERR2STR (IDN2_UNASSIGNED);
case IDN2_BIDI: return ERR2STR (IDN2_BIDI);
case IDN2_DOT_IN_LABEL: return ERR2STR (IDN2_DOT_IN_LABEL);
case IDN2_INVALID_TRANSITIONAL: return ERR2STR (IDN2_INVALID_TRANSITIONAL);
case IDN2_INVALID_NONTRANSITIONAL: return ERR2STR (IDN2_INVALID_NONTRANSITIONAL);
default: return "IDN2_UNKNOWN";
}

return p;
}
@@ -26,10 +26,11 @@
not, see <http://www.gnu.org/licenses/>.
*/

#ifndef _IDN2_H
#define _IDN2_H
#ifndef IDN2_H
#define IDN2_H

/* *INDENT-OFF* */
/* see https://www.gnu.org/software/gnulib/manual/html_node/Exported-Symbols-of-Shared-Libraries.html */
#ifndef _IDN2_API
# if defined IDN2_BUILDING && defined HAVE_VISIBILITY && HAVE_VISIBILITY
# define _IDN2_API __attribute__((__visibility__("default")))
@@ -51,39 +52,66 @@ extern "C"
{
#endif

/**
* GCC_VERSION_AT_LEAST
*
* Pre-processor symbol to check the gcc version.
*/
#if defined __GNUC__ && defined __GNUC_MINOR__
# define GCC_VERSION_AT_LEAST(major, minor) ((__GNUC__ > (major)) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
#else
# define GCC_VERSION_AT_LEAST(major, minor) 0
#endif

/* the following G_GNUC_ prefixes are for gtk-doc to recognize the attributes */

/**
* G_GNUC_IDN2_ATTRIBUTE_PURE
*
* Function attribute: Function is a pure function.
*/
#if GCC_VERSION_AT_LEAST(2,96)
# define G_GNUC_IDN2_ATTRIBUTE_PURE __attribute__ ((pure))
#else
# define G_GNUC_IDN2_ATTRIBUTE_PURE
#endif

/**
* G_GNUC_IDN2_ATTRIBUTE_CONST
*
* Function attribute: Function is a const function.
*/
#if GCC_VERSION_AT_LEAST(2,5)
# define G_GNUC_IDN2_ATTRIBUTE_CONST __attribute__ ((const))
#else
# define G_GNUC_IDN2_ATTRIBUTE_CONST
#endif

/**
* G_GNUC_DEPRECATED
*
* Function attribute: Function is deprecated.
*/
#if GCC_VERSION_AT_LEAST(3,1)
# define G_GNUC_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
# define G_GNUC_DEPRECATED __declspec(deprecated)
#else
# define G_GNUC_DEPRECATED /* empty */
#endif

/**
* G_GNUC_UNUSED
*
* Parameter attribute: Parameter is not used.
*/

/* the following G_GNUC_ prefix is for gtk-doc to recognize the attributes */
#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
# define _IDN2_ATTRIBUTE_PURE __attribute__ ((__pure__))
# define _IDN2_ATTRIBUTE_CONST __attribute__ ((__const__))
# define G_GNUC_IDN2_ATTRIBUTE_PURE __attribute__ ((__pure__))
# define G_GNUC_IDN2_ATTRIBUTE_CONST __attribute__ ((__const__))
#if GCC_VERSION_AT_LEAST(2,95)
# define G_GNUC_UNUSED __attribute__ ((__unused__))
#else
# define _IDN2_ATTRIBUTE_PURE /* empty */
# define _IDN2_ATTRIBUTE_CONST /* empty */
# define G_GNUC_IDN2_ATTRIBUTE_PURE /* empty */
# define G_GNUC_IDN2_ATTRIBUTE_CONST /* empty */
# define G_GNUC_UNUSED /* empty */
#endif


/**
* IDN2_VERSION
*
@@ -263,8 +291,10 @@ extern "C"

/* Auxiliary functions. */

extern _IDN2_API int
extern _IDN2_API G_GNUC_DEPRECATED int
idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags);
extern _IDN2_API int
idn2_to_ascii_4i2 (const uint32_t * input, size_t inlen, char ** output, int flags);
extern _IDN2_API int
idn2_to_ascii_4z (const uint32_t * input, char ** output, int flags);
extern _IDN2_API int
@@ -273,7 +303,7 @@ extern "C"
idn2_to_ascii_lz (const char * input, char ** output, int flags);

extern _IDN2_API int
idn2_to_unicode_8z4z (const char * input, uint32_t ** output, int flags G_GNUC_UNUSED);
idn2_to_unicode_8z4z (const char * input, uint32_t ** output, G_GNUC_UNUSED int flags);
extern _IDN2_API int
idn2_to_unicode_4z4z (const uint32_t * input, uint32_t ** output, int flags);
extern _IDN2_API int
@@ -285,13 +315,13 @@ extern "C"
extern _IDN2_API int
idn2_to_unicode_lzlz (const char * input, char ** output, int flags);

extern _IDN2_API const char *
idn2_strerror (int rc) G_GNUC_IDN2_ATTRIBUTE_CONST;
extern _IDN2_API const char *
idn2_strerror_name (int rc) G_GNUC_IDN2_ATTRIBUTE_CONST;
extern _IDN2_API G_GNUC_IDN2_ATTRIBUTE_CONST const char *
idn2_strerror (int rc);
extern _IDN2_API G_GNUC_IDN2_ATTRIBUTE_CONST const char *
idn2_strerror_name (int rc);

extern _IDN2_API const char *
idn2_check_version (const char *req_version) G_GNUC_IDN2_ATTRIBUTE_PURE;
extern _IDN2_API G_GNUC_IDN2_ATTRIBUTE_PURE const char *
idn2_check_version (const char *req_version);

extern _IDN2_API void
idn2_free (void *ptr);
@@ -346,4 +376,4 @@ extern "C"
}
#endif

#endif /* _IDN2_H */
#endif /* IDN2_H */
@@ -27,10 +27,10 @@ IDN2_0.0.0 {
idn2_decode_ul;
idn2_register_ul;

idn2_to_ascii_4i;
idn2_to_ascii_4z;
idn2_to_ascii_8z;
idn2_to_ascii_lz;
idn2_to_ascii_4i;
idn2_to_ascii_4z;
idn2_to_ascii_8z;
idn2_to_ascii_lz;

idn2_to_unicode_8z4z;
idn2_to_unicode_4z4z;
@@ -42,10 +42,11 @@ IDN2_0.0.0 {
idn2_strerror;
idn2_strerror_name;

# Internal self-test use only.
_idn2_punycode_encode;
_idn2_punycode_decode;

local:
*;
};

IDN2_2.1.0 {
global:
idn2_to_ascii_4i2;
} IDN2_0.0.0;
@@ -28,11 +28,10 @@

#include <config.h>

#include "idn2.h"

#include <stdlib.h> /* free */
#include <errno.h> /* errno */

#include "idn2.h"
#include "bidi.h"
#include "tables.h"
#include "context.h"
@@ -45,17 +44,14 @@

#include "idna.h"

static int
_isNFC (uint32_t * label, size_t len) _GL_ATTRIBUTE_PURE;

/*
* NFC Quick Check from
* http://unicode.org/reports/tr15/#Detecting_Normalization_Forms
*
* They say, this is much faster than 'brute force' normalization.
* Strings are very likely already in NFC form.
*/
static int
G_GNUC_IDN2_ATTRIBUTE_PURE static int
_isNFC (uint32_t * label, size_t len)
{
int lastCanonicalClass = 0;
@@ -26,8 +26,12 @@
not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIBIDN2_IDNA_H
#define LIBIDN2_IDNA_H

#include <stdint.h>
#include <stdbool.h>
#include "idn2.h"

enum
{
@@ -53,9 +57,14 @@ enum
TEST_ALLOW_STD3_DISALLOWED = 0x4000,
};

extern int _idn2_u8_to_u32_nfc (const uint8_t * src, size_t srclen,
uint32_t ** out, size_t * outlen, int nfc);
extern int
_idn2_u8_to_u32_nfc (const uint8_t * src, size_t srclen,
uint32_t ** out, size_t * outlen, int nfc);

extern G_GNUC_IDN2_ATTRIBUTE_PURE bool
_idn2_ascii_p (const uint8_t * src, size_t srclen);

extern bool _idn2_ascii_p (const uint8_t * src, size_t srclen) _GL_ATTRIBUTE_PURE;
extern int
_idn2_label_test (int what, const uint32_t * label, size_t llen);

extern int _idn2_label_test (int what, const uint32_t * label, size_t llen);
#endif /* LIBIDN2_IDNA_H */
@@ -209,6 +209,14 @@ _tr46 (const uint8_t * domain_u8, uint8_t ** out, int flags)
}
}

/* Exit early if result is too long.
* This avoids excessive CPU usage in punycode encoding, which is O(N^2). */
if (len2 >= IDN2_DOMAIN_MAX_LENGTH)
{
free (domain_u32);
return IDN2_TOO_BIG_DOMAIN;
}

uint32_t *tmp = (uint32_t *) malloc ((len2 + 1) * sizeof (uint32_t));
if (!tmp)
{
@@ -547,9 +555,11 @@ idn2_lookup_ul (const char * src, char ** lookupname, int flags)
* idn2_to_ascii_4i:
* @input: zero terminated input Unicode (UCS-4) string.
* @inlen: number of elements in @input.
* @output: pointer to newly allocated zero-terminated output string.
* @output: output zero terminated string that must have room for at least 63 characters plus the terminating zero.
* @flags: optional #idn2_flags to modify behaviour.
*
* THIS FUNCTION HAS BEEN DEPRECATED DUE TO A DESIGN FLAW. USE idn2_to_ascii_4i2() INSTEAD !
*
* The ToASCII operation takes a sequence of Unicode code points that make
* up one domain label and transforms it into a sequence of code points in
* the ASCII range (0..7F). If ToASCII succeeds, the original sequence and
@@ -579,6 +589,69 @@ idn2_lookup_ul (const char * src, char ** lookupname, int flags)
**/
int
idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags)
{
char *out;
int rc;

if (!input)
{
if (output)
*output = 0;
return IDN2_OK;
}

rc = idn2_to_ascii_4i2 (input, inlen, &out, flags);
if (rc == IDN2_OK)
{
size_t len = strlen(out);

if (len > 63)
rc = IDN2_TOO_BIG_DOMAIN;
else if (output)
memcpy (output, out, len);

free (out);
}

return rc;
}

/**
* idn2_to_ascii_4i:
* @input: zero terminated input Unicode (UCS-4) string.
* @inlen: number of elements in @input.
* @output: pointer to newly allocated zero-terminated output string.
* @flags: optional #idn2_flags to modify behaviour.
*
* The ToASCII operation takes a sequence of Unicode code points that make
* up one domain label and transforms it into a sequence of code points in
* the ASCII range (0..7F). If ToASCII succeeds, the original sequence and
* the resulting sequence are equivalent labels.
*
* It is important to note that the ToASCII operation can fail.
* ToASCII fails if any step of it fails. If any step of the
* ToASCII operation fails on any label in a domain name, that domain
* name MUST NOT be used as an internationalized domain name.
* The method for dealing with this failure is application-specific.
*
* The inputs to ToASCII are a sequence of code points.
*
* ToASCII never alters a sequence of code points that are all in the ASCII
* range to begin with (although it could fail). Applying the ToASCII operation multiple
* effect as applying it just once.
*
* The default behavior of this function (when flags are zero) is to apply
* the IDNA2008 rules without the TR46 amendments. As the TR46
* non-transitional processing is nowadays ubiquitous, when unsure, it is
* recommended to call this function with the %IDN2_NONTRANSITIONAL
* and the %IDN2_NFC_INPUT flags for compatibility with other software.
*
* Return value: Returns %IDN2_OK on success, or error code.
*
* Since: 2.1.1
**/
int
idn2_to_ascii_4i2 (const uint32_t * input, size_t inlen, char ** output, int flags)
{
uint32_t *input_u32;
uint8_t *input_u8, *output_u8;
@@ -588,7 +661,7 @@ idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags
if (!input)
{
if (output)
*output = 0;
*output = NULL;
return IDN2_OK;
}

@@ -613,15 +686,12 @@ idn2_to_ascii_4i (const uint32_t * input, size_t inlen, char * output, int flags

if (rc == IDN2_OK)
{
/* wow, this is ugly, but libidn manpage states:
* char * out output zero terminated string that must have room for at
* least 63 characters plus the terminating zero.
*/
if (output)
strcpy (output, (const char *) output_u8);
*output = (char *) output_u8;
else
free (output_u8);
}

free(output_u8);
return rc;
}

@@ -68,6 +68,7 @@
#define punycode_success IDN2_OK
#define punycode_overflow IDN2_PUNYCODE_OVERFLOW
#define punycode_big_output IDN2_PUNYCODE_BIG_OUTPUT
#define punycode_bad_input IDN2_PUNYCODE_BAD_INPUT
#define punycode_encode _idn2_punycode_encode

/**********************************************************/
@@ -158,8 +159,8 @@ int punycode_encode(
if (max_out - out < 2) return punycode_big_output;
output[out++] = (char) input[j];
}
/* else if (input[j] < n) return punycode_bad_input; */
/* (not needed for Punycode with unsigned code points) */
else if (input[j] > 0x10FFFF || (input[j] >= 0xD800 && input[j] <= 0xDBFF))
return punycode_bad_input;
}

h = b = (punycode_uint) out;
@@ -26,6 +26,9 @@
not, see <http://www.gnu.org/licenses/>.
*/

#ifndef LIBIDN2_PUNYCODE_H
#define LIBIDN2_PUNYCODE_H

#include <stddef.h>
#include <stdint.h>

@@ -39,3 +42,5 @@ _idn2_punycode_decode (size_t input_length,
const char input[],
size_t * output_length,
uint32_t output[]);

#endif /* LIBIDN2_PUNYCODE_H */
@@ -26,9 +26,19 @@
not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>
#ifndef LIBIDN2_TABLES_H
#define LIBIDN2_TABLES_H

int _idn2_disallowed_p (uint32_t cp) _GL_ATTRIBUTE_CONST;
int _idn2_contextj_p (uint32_t cp) _GL_ATTRIBUTE_CONST;
int _idn2_contexto_p (uint32_t cp) _GL_ATTRIBUTE_CONST;
int _idn2_unassigned_p (uint32_t cp) _GL_ATTRIBUTE_CONST;
#include <stdint.h>
#include "idn2.h"

int G_GNUC_IDN2_ATTRIBUTE_CONST
_idn2_disallowed_p (uint32_t cp);
int G_GNUC_IDN2_ATTRIBUTE_CONST
_idn2_contextj_p (uint32_t cp);
int G_GNUC_IDN2_ATTRIBUTE_CONST
_idn2_contexto_p (uint32_t cp);
int G_GNUC_IDN2_ATTRIBUTE_CONST
_idn2_unassigned_p (uint32_t cp);

#endif /* LIBIDN2_TABLES_H */
@@ -32,6 +32,7 @@
#include <stdlib.h> /* bsearch */
#include <string.h> /* memset */

#include "tr46map.h"
#include "tr46map_data.c"

#define countof(a) (sizeof(a)/sizeof(*(a)))
@@ -136,7 +137,7 @@ map_is (const IDNAMap * map, unsigned flags)
return (idna_flags[map->flag_index] & flags) == flags;
}

static int
static int G_GNUC_IDN2_ATTRIBUTE_PURE
_compare_nfcqc_map (uint32_t * c, NFCQCMap * m2)
{
if (*c < m2->cp1)