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

Domains with underscores are considered as invalid #33

Closed
rozhn0v opened this issue Aug 5, 2020 · 7 comments
Closed

Domains with underscores are considered as invalid #33

rozhn0v opened this issue Aug 5, 2020 · 7 comments

Comments

@rozhn0v
Copy link

rozhn0v commented Aug 5, 2020

Hello! The library fails to parse domains with underscores.

let list = List::fetch().unwrap();
let domain = list.parse_domain("_jabber._tcp.gmail.com")
    .expect("underscores in labels are valid");
@eggyal
Copy link

eggyal commented Oct 17, 2020

This appears to be what List::parse_dns_name was introduced for, however if the root contains an underscore (or any other byte that's valid in a DNS label but not in a hostname) then the following check causes DnsName::domain to return None which surely is not correct?

if Domain::has_valid_syntax(&root) {

Can we remove this check, please?

@eggyal
Copy link

eggyal commented Oct 17, 2020

Actually, per #7 (comment):

Some people, myself included, are using this library to validate "registrable" domain names. As such, domain.root() must only return registrable domain names.

Nothing in the standards prevent registries from offering for registration domains containing bytes that are disallowed in hostnames, though I accept as a matter of policy most if not all do impose such a restriction. So whether this check strictly belongs in this library is not so clear.

However, if it is to remain, could we instead add root and suffix methods to DnsName that bypass these checks?

@rushmorem
Copy link
Owner

Can we remove this check, please?

@eggyal psl sounds like a better fit for your use case. It's lower level and only checks to see if the input ends with a public suffix. It doesn't try to validate the syntax of the hostname. As a bonus it's much faster, doesn't have any dependencies and it is no_std.

@rushmorem
Copy link
Owner

@eggyal Does this API work well for your use case? It should eliminate any false negatives you were having but your feedback here is highly appreciated.

@eggyal
Copy link

eggyal commented Mar 4, 2021

I've taken a quick look and indeed it does appear to fit the bill. Thanks @rushmorem !

@rushmorem
Copy link
Owner

Awesome! Thanks for the feedback.

@rushmorem
Copy link
Owner

I believe this is now fixed, both in this crate and in addr where parse_dns_name was moved to.

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

3 participants