From e8ee6b4a19a90b4251744b7d9078dd1865fa4823 Mon Sep 17 00:00:00 2001 From: MapleCool <37971849+pmkol@users.noreply.github.com> Date: Thu, 23 Oct 2025 18:40:39 +0800 Subject: [PATCH 1/2] fix: allow underscores during IDNA conversion --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b3742b9..574d04e 100644 --- a/main.go +++ b/main.go @@ -326,11 +326,13 @@ All long form (--) flags can be toggled with the dig-standard +[no]flag notation // Skip if already an in-addr.arpa or ip6.arpa name lowerName := strings.ToLower(opts.Name) if !strings.HasSuffix(lowerName, ".in-addr.arpa") && !strings.HasSuffix(lowerName, ".ip6.arpa") { - asciiName, err := idna.Lookup.ToASCII(opts.Name) + // Allow underscores during IDNA conversion + _asciiName := strings.ReplaceAll(opts.Name, "_", "..") + asciiName, err := idna.Lookup.ToASCII(_asciiName) if err != nil { return fmt.Errorf("idna toascii: %s", err) } - opts.Name = asciiName + opts.Name = strings.ReplaceAll(asciiName, "..", "_") } } From e47d199455e0ad1ea7163286398f2d19b620d30d Mon Sep 17 00:00:00 2001 From: Nate Sales Date: Mon, 27 Oct 2025 23:39:25 -0400 Subject: [PATCH 2/2] test: add idna test --- main_test.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main_test.go b/main_test.go index 2032634..0dc04b1 100644 --- a/main_test.go +++ b/main_test.go @@ -612,3 +612,16 @@ func TestMainTypeNotation(t *testing.T) { assert.Nil(t, err) assert.Regexp(t, regexp.MustCompile(`cloudflare.com. .* HTTPS .*`), outType65.String()) } + +func TestIDNAUnderscoreASCII(t *testing.T) { + // Ensure ASCII names with underscores are not mangled by IDNA processing + out, err := run( + "--all", + "-q", "_acme-challenge.example.com", + "-t", "TXT", + ) + assert.Nil(t, err) + // Expect the question or answer to include the literal underscore name + re := regexp.MustCompile(regexp.QuoteMeta("_acme-challenge.example.com.")) + assert.Regexp(t, re, out.String()) +}