diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 3dac5aa28b..692ea5ccac 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -552,6 +552,8 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg, UNUSED(msgbuf); + dig_idnsetup(query->lookup, true); + styleflags |= DNS_STYLEFLAG_REL_OWNER; if (yaml) { msg->indent.string = " "; @@ -912,6 +914,9 @@ repopulate_buffer: if (style != NULL) { dns_master_styledestroy(&style, mctx); } + + dig_idnsetup(query->lookup, false); + return (result); } diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index c3e428fb0e..525bf53dc8 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -2117,10 +2117,6 @@ setup_lookup(dig_lookup_t *lookup) { #ifdef HAVE_LIBIDN2 char idn_origin[MXNAME], idn_textname[MXNAME]; - - result = dns_name_settotextfilter(lookup->idnout ? idn_output_filter - : NULL); - check_result(result, "dns_name_settotextfilter"); #endif /* HAVE_LIBIDN2 */ INSIST(!free_now); @@ -4234,10 +4230,6 @@ cancel_all(void) { */ void destroy_libs(void) { -#ifdef HAVE_LIBIDN2 - isc_result_t result; -#endif /* HAVE_LIBIDN2 */ - if (keep != NULL) { isc_nmhandle_detach(&keep); } @@ -4275,11 +4267,6 @@ destroy_libs(void) { clear_searchlist(); -#ifdef HAVE_LIBIDN2 - result = dns_name_settotextfilter(NULL); - check_result(result, "dns_name_settotextfilter"); -#endif /* HAVE_LIBIDN2 */ - if (commctx != NULL) { debug("freeing commctx"); isc_mempool_destroy(&commctx); @@ -4476,3 +4463,17 @@ idn_ace_to_locale(const char *src, char **dst) { *dst = local_src; } #endif /* HAVE_LIBIDN2 */ + +void +dig_idnsetup(dig_lookup_t *lookup, bool active) { +#ifdef HAVE_LIBIDN2 + isc_result_t result; + result = dns_name_settotextfilter( + (active && lookup->idnout) ? idn_output_filter : NULL); + check_result(result, "dns_name_settotextfilter"); +#else + UNUSED(lookup); + UNUSED(active); + return; +#endif /* HAVE_LIBIDN2 */ +} diff --git a/bin/dig/dighost.h b/bin/dig/dighost.h index f9bbaf92d3..2e3278ae06 100644 --- a/bin/dig/dighost.h +++ b/bin/dig/dighost.h @@ -388,32 +388,38 @@ setup_text_key(void); * Routines exported from dig.c for use by dig for iOS */ -/*%< +/*% * Call once only to set up libraries, parse global * parameters and initial command line query parameters */ void dig_setup(int argc, char **argv); -/*%< +/*% * Call to supply new parameters for the next lookup */ void dig_query_setup(bool, bool, int argc, char **argv); -/*%< +/*% * set the main application event cycle running */ void dig_startup(void); -/*%< +/*% * Initiates the next lookup cycle */ void dig_query_start(void); -/*%< +/*% + * Activate/deactivate IDN filtering of output. + */ +void +dig_idnsetup(dig_lookup_t *lookup, bool active); + +/*% * Cleans up the application */ void