use idn2 instead of libidn2 to avoid the need for GPL3+ license
This commit is contained in:
parent
eaf4f01b78
commit
3b94a03638
|
@ -22,7 +22,7 @@ libpsl_inline_@LIBPSL_API_VERSION@_la_LDFLAGS = -version-info $(LIBPSL_SO_VERSIO
|
|||
noinst_PROGRAMS = psl2c
|
||||
psl2c_SOURCES = psl2c.c
|
||||
psl2c_CPPFLAGS = -I$(top_srcdir)/include -D _GNU_SOURCE
|
||||
psl2c_LDADD = -lidn2
|
||||
#psl2c_LDADD = -lidn2
|
||||
#psl2c_LDFLAGS = -static
|
||||
|
||||
# Build rule for suffix.c
|
||||
|
|
19
src/psl2c.c
19
src/psl2c.c
|
@ -71,7 +71,9 @@ static void _add_punycode_if_needed(_psl_vector_t *v)
|
|||
|
||||
if (_str_needs_encoding(e->label_buf)) {
|
||||
_psl_entry_t suffix;
|
||||
char *asc = NULL;
|
||||
|
||||
// the following lines will have GPL3+ license issues
|
||||
/* char *asc = NULL;
|
||||
int rc;
|
||||
|
||||
if ((rc = idn2_lookup_u8((uint8_t *)e->label_buf, (uint8_t **)&asc, 0)) == IDN2_OK) {
|
||||
|
@ -81,6 +83,21 @@ static void _add_punycode_if_needed(_psl_vector_t *v)
|
|||
_vector_add(v, &suffix);
|
||||
} else
|
||||
fprintf(stderr, "toASCII(%s) failed (%d): %s\n", e->label_buf, rc, idn2_strerror(rc));
|
||||
*/
|
||||
|
||||
// this is much slower than the libidn2 API but should have no license issues
|
||||
FILE *pp;
|
||||
char cmd[16 + strlen(e->label_buf)], lookupname[64] = "";
|
||||
snprintf(cmd, sizeof(cmd), "idn2 '%s'", e->label_buf);
|
||||
if ((pp = popen(cmd, "r"))) {
|
||||
if (fscanf(pp, "%63s", lookupname) >= 1) {
|
||||
_suffix_init(&suffix, lookupname, strlen(lookupname));
|
||||
suffix.wildcard = e->wildcard;
|
||||
_vector_add(v, &suffix);
|
||||
}
|
||||
pclose(pp);
|
||||
} else
|
||||
fprintf(stderr, "Failed to call popen(%s, \"r\")\n", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue