Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider setting use_std3_ascii_rules=false to support underscores #75

Open
eminence opened this issue Jul 14, 2021 · 1 comment
Open

Comments

@eminence
Copy link

Currently dog will set use_std3_ascii_rules: true when doing IDNA label conversion:

dns/src/strings.rs:25:

#[cfg(feature = "with_idna")]
fn label_to_ascii(label: &str) -> Result<String, unic_idna::Errors> {
    let flags = unic_idna::Flags{use_std3_ascii_rules: true, transitional_processing: false, verify_dns_length: true};
    unic_idna::to_ascii(label, flags)
}

This prevents domain names with an underscore (_) from being resolved. Underscores are common in SRV records.

Here is an example of dog in its current state:

$ cargo run -- _xmpp-client._tcp.gmail.com SRV
    Finished dev [unoptimized] target(s) in 0.28s
     Running `target/debug/dog _xmpp-client._tcp.gmail.com SRV`
dog: Invalid options: Invalid domain "_xmpp-client._tcp.gmail.com"

Here's what dig will return for the same domain:

$ dig _xmpp-client._tcp.gmail.com SRV +nostats +nocomments

; <<>> DiG 9.11.5-P4-5.1+deb10u5-Debian <<>> _xmpp-client._tcp.gmail.com SRV +nostats +nocomments
;; global options: +cmd
;_xmpp-client._tcp.gmail.com.   IN      SRV
_xmpp-client._tcp.gmail.com. 839 IN     SRV     20 0 5222 alt3.xmpp.l.google.com.
_xmpp-client._tcp.gmail.com. 839 IN     SRV     20 0 5222 alt4.xmpp.l.google.com.
_xmpp-client._tcp.gmail.com. 839 IN     SRV     20 0 5222 alt2.xmpp.l.google.com.
_xmpp-client._tcp.gmail.com. 839 IN     SRV     5 0 5222 xmpp.l.google.com.
_xmpp-client._tcp.gmail.com. 839 IN     SRV     20 0 5222 alt1.xmpp.l.google.com.

If dog is modified to not enforce std3 ascii rules, we get the output expected:

$ cargo run -- _xmpp-client._tcp.gmail.com SRV
    Finished dev [unoptimized] target(s) in 0.19s
     Running `target/debug/dog _xmpp-client._tcp.gmail.com SRV`
SRV _xmpp-client._tcp.gmail.com. 13m13s   20 0 "alt1.xmpp.l.google.com.":5222
SRV _xmpp-client._tcp.gmail.com. 13m13s   20 0 "alt3.xmpp.l.google.com.":5222
SRV _xmpp-client._tcp.gmail.com. 13m13s   20 0 "alt4.xmpp.l.google.com.":5222
SRV _xmpp-client._tcp.gmail.com. 13m13s   20 0 "alt2.xmpp.l.google.com.":5222
SRV _xmpp-client._tcp.gmail.com. 13m13s   5 0 "xmpp.l.google.com.":5222

Thanks!

See also: https://www.unicode.org/reports/tr46/#UseSTD3ASCIIRules

@noperator
Copy link

Ran into this issue today, and had to resort to using dig to resolve a subdomain containing an underscore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants