File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -328,13 +328,19 @@ All long form (--) flags can be toggled with the dig-standard +[no]flag notation
328328 // Skip if already an in-addr.arpa or ip6.arpa name
329329 lowerName := strings .ToLower (opts .Name )
330330 if ! strings .HasSuffix (lowerName , ".in-addr.arpa" ) && ! strings .HasSuffix (lowerName , ".ip6.arpa" ) {
331- // Allow underscores during IDNA conversion
332- _asciiName := strings .ReplaceAll (opts .Name , "_" , ".." )
333- asciiName , err := idna .Lookup .ToASCII (_asciiName )
331+ // Use a custom IDNA profile to allow underscores (non-LDH characters).
332+ // Standard IDNA Lookup enforces STD3 rules which forbid underscores,
333+ // but they are valid in DNS records (e.g. TXT, SRV).
334+ p := idna .New (
335+ idna .MapForLookup (),
336+ idna .StrictDomainName (false ),
337+ )
338+
339+ asciiName , err := p .ToASCII (opts .Name )
334340 if err != nil {
335341 return fmt .Errorf ("idna toascii: %s" , err )
336342 }
337- opts .Name = strings . ReplaceAll ( asciiName , ".." , "_" )
343+ opts .Name = asciiName
338344 }
339345 }
340346
You can’t perform that action at this time.
0 commit comments