-
Notifications
You must be signed in to change notification settings - Fork 136
Domainkey: Underscore in hostname #102
Comments
I second this. Maybe some sort of option to permit this pattern? |
Using underscores in hostnames can cause more problems on network level. See also 'Restrictions on valid hostnames' on https://en.wikipedia.org/wiki/Hostname. Also; actually the underscore is the uppercase for "-", as it comes when shift plus "-" are pressed. ;) All hostnames are lowercase. |
why it is impossible to realize optional check? |
@bacinsky all known dns of the server support validation of underscore in hostname long ago, but developers refer to RFC. |
@bacinsky You should've known in the first place that underscores are illegal characters for (sub)domainnames, so you can't expect a whole framework to bend for it, just because you want to and because you lack proper implementations. You really should read the Wikipedia article I linked before, as it clearly explaines why an underscore can't be correctly used in hostnames. |
@bacinsky If you've read the Wikipedia article, you've seen that underscores can be used for something else within DNS. More specific:
So my actual advice is to proper implement things like they were intended to, to avoid problems later on. |
@CptChaos "underscore can't be correctly used in hostnames" - please proof. DKIM,DMARC,SRV,TLSA - properly works. |
@038291 You've actually just proven my point exactly. DKIM, SRV, DMARC, TLSA and such aren't hostnames. More info upon the subject; read the linked wikipedia article and try to read about DNS and how it works and what it's (im)possibilities are. |
@CptChaos Leaves so that it is necessary to write the separate DNS RRSet's validator. Hostname validator isn't suitable for these purposes. Thanks. |
This looks like a case for a new Domainkey validator |
I solved this problem in a tricky way. I created an FqdnValidator. It has two options: allowUnderscore and allowWildcard. The FqdnValidator internally uses the Zend Hostname validator. First, the FQDN string (e.g. abc.example.com) is split into the TLD (com), domain (example) and subdomain (abc) parts. It is a little bit against the official terminology, but what is important, is that the underscore as well as a wildcard (*) characters are only allowed for some DNS Records and only as a subdomain part. So, when the allowUnderscore option is enabled, the underscore is replaced with 'x' character in all subdomains. The domain part (i.e. 'example') is not affected. The string is passed then to the Hostname validator. When the allowWildcard option is enabled, each subdomain part is checked if it contains only one character and this character is the asterix (*). If this assertion is ok, the asterix is replaced with 'x' and passed to the Hostname validator. The hardest thing to do here is to split the FQDN into the parts. For instance, some TLDs contain dot inside, i.e. in both cases example.de.com and example.com the domain name part is 'example'. You'll need to maintain the list of TLDs to achieve this splitting. Sorry, but I can not share the solution I did because the FqdnValidator is a Symfony validator and the list of TLDs is loaded from the DB dynamically. |
@038291 Sorry for the late response. On the page you linked, you can also read:
So yes, hostnames (like for web addresses) actually can't have a _ in them. ;) @crzdeveloper How would you solve this when a subdomain has an x in it, like when you have example.example2.tld? ;) I would also no use a DB to store tld's, but rather configfiles or something similar. It's not likely TLD's are going to change much. ;) Keeping it from a DB makes it a bit faster, as you do not have to build another connection, query the database and wait for the results. |
This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#27. |
default._domainkey.example.com
[hostnameInvalidHostnameSchema]: The input appears to be a DNS hostname but cannot match against hostname schema for TLD 'COM'
[hostnameInvalidLocalName]: The input does not appear to be a valid local network name
The text was updated successfully, but these errors were encountered: