FILTER_VALIDATE_DOMAIN checks conformance with DNS RFCs : total length, label length and allowed characters (_ are allowed in domain names but many other characters are forbidden such as ~/+...). I'll add IDN support too when IDN support for streams will be merged.
FILTER_VALIDATE_URL checks conformance with URL RFCs (and not URI, as discussed on GitHub). URL's host part RFCs conformance implies DNS RFCs conformance, IPv4 and IPv6 RFCs conformance + some additional checks (no underscore allowed in hostnames and IPv6 enclosed with brackets for instance). It's why I've added the convenience flag FILTER_FLAG_HOSTNAME. Btw, there is many use case for validating that a string is a valid domain (or a valid hostname): hoster and registar apps, mail server management apps and anything else DNS related. Maybe be can we find a better name for FILTER_VALIDATE_DOMAIN. Such as FILTER_VALIDATE_DOMAIN_NAME or FILTER_VALIDATE_DNS_DOMAIN (a bit redundant, DNS = Domain Name System) but please not something related "DNS Record" because a valid DNS record can have the following format: les-tilleuls.coop. 3600 IN SOA monsite.nnx.com .root.monsite.nnx.com. ( 2014092300 ; serial 21600 ; refresh (6 hours) 3600 ; retry (1 hour) 604800 ; expire (1 week) 86400 ; minimum (1 day) ) 2014-11-06 13:55 GMT+01:00 Andrey Andreev <n...@devilix.net>: > Hi, > > On Thu, Nov 6, 2014 at 8:19 AM, Kévin Dunglas <dung...@gmail.com> wrote: > > Hi Andrey, > > > > Sorry but I think you're wrong. Domain != hostname. Underscore are > allowed > > in domains (RFC 2181) but not in hostnames (RFC 1123 and next). To quote > > Wikipedia: > > > > "While a hostname may not contain other characters, such as the > underscore > > character (_), other DNS names may contain the underscore. Systems such > > asDomainKeys and service records use the underscore as a means to assure > > that their special character is not confused with hostnames. For > > example,_http._sctp.www.example.com specifies a service pointer for an > SCTP > > capable webserver host (www) in the domain example.com." > > http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names > > > > You can also see this StackOverflow answer > > http://stackoverflow.com/a/2183140/1352334 > > I agree to an extent, but that is highly contextual. > > Who said that 'domain' === 'DNS record' (which is a very broad term > anyway)? And IF we assume this, why do you need FILTER_VALIDATE_DOMAIN > for it if it's only going to check length? > > Cheers, > Andrey. > -- Kévin Dunglas Consultant et développeur freelance http://dunglas.fr Tél. : 06 60 91 20 20