Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "..", "_")
}
}

Expand Down
13 changes: 13 additions & 0 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}