-
Notifications
You must be signed in to change notification settings - Fork 517
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
Provide something like is_dnsname(s: str) -> bool
and is_fqdn(s: str) -> bool
#1019
Comments
Dnspython already does this, as Here's an example program to show how you could check for hostname-ness, and also showing different ways of dealing with the relativity / absoluteness of text names:
|
P.S. my is_hostname() isn't quite right as it allows the root name to be a hostname, which isn't right :). It should probably check that the name is absolute and that the number of labels is > 1. |
Thank you. I failed to distinguish between valid hostname and valid domain name. My intent was for hostname, and so this is not where I should have been looking. So it is fit and proper that labels in domain names be much more liberal than what is required for hostnames. So it's not this package that should be providing hostname validation. So the relevant standards for hostnames are RFC 952 updated with the "3Com amendment" in RFC 1123 allowing leading digits. But of course a valid hostname has to meet both those and also be valid domain names. (So the limits on label lengths apply.) I'm still not sure which standard tells me that the last non-root component of a hostname can't be all digits, but I see it the fact referred to in RFC 1123 §2.1 Well, this all could we worse. I would be trying to synoptically validate email address. |
Funnily enough, e-mail might be a (good) special case. In theory you could take the whole |
Maybe lemme add an example: You can compare |
I wasn't talking about MX records, I was talking about the fact that RFCs {8,28,53}22 literally allow comments in the part of the address after an "
Is valid, even with the newline.
is not valid, because there needs to be white space after the newline. The rules for the local part of the address are even more complicated. |
Oh, sorry! We were talking completely different topics then. |
Motivation
I am trying to handle Mastodon addresses, which are of the form "
[email protected]
". See sinaatalay/rendercv#10 for my attempt.In doing so, I was unable to find a RFC compliant validator for domain names. It is possible that there is a python package that does what I was seeking, but I failed to find it. I feel that dnspython would be the most natural place for it.
I will also add (though this might be a separate bug report) that
dns.name()
does not validate whether all of the bytes within a label are valid. For example, I would have expected an error fromSo what I am seeking would require additional label validation beyond what
dns.name._validate_labels()
. I do not know whether the behavior with ofname.from_text()
and_validate_labels()
is intended in this respect. So I don't know whether making_validate_labels()
stricter is the correct approach.Describe the solution you'd like.
I would like a method (or two) in dns.name which tells me if I have a syntactically valid domain name. I would also like to have a related method which tells me if I have a syntactically valid fully qualified domain name (with an optional argument on whether the root "." is required.
The text was updated successfully, but these errors were encountered: