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

Already on GitHub? Sign in to your account

"http://somedomain.com" is detected as a valid domain #15

rb2k opened this Issue Feb 7, 2012 · 5 comments


None yet
2 participants

rb2k commented Feb 7, 2012

I don't think this should happen seeing as it's an URL, not a domain

 => true 

weppos commented Feb 7, 2012

Good catch!

The method should probably check if the passed string contains a scheme. Or do you have a better proposal to handle this issue (or related ones)?


rb2k commented Feb 7, 2012

I'd think we can probably just check the string for a "://" scheme. Neither of these characters is allowed in a domain anyway.
Maybe we can create a list of characters that aren't allowed and just check for those?


weppos commented Feb 7, 2012

Maybe we can create a list of characters that aren't allowed and just check for those?

This is an other solution I was thinking about. I'm just wondering if this solution wouldn't cause some issue with IDN domains.


rb2k commented Feb 7, 2012

I think at least ':' and '/' are never allowed as part of a domain name, not even in punycode.


weppos commented Feb 7, 2012

Yes. I will probably check for a presence of a scheme pattern ://, this is the simplest way to solve the issue.

@razorinc razorinc pushed a commit to razorinc/public_suffix_service that referenced this issue Mar 5, 2012

Francesco Vollero This patch should close #15 eac6d8c

@weppos weppos closed this in 042e773 Mar 16, 2012

@weppos weppos self-assigned this Nov 23, 2014

@weppos weppos added a commit that referenced this issue Nov 23, 2014

@weppos weppos Add validation false positive
This is a list of cases where PublicSuffix.valid? returns true and the
domain is apparently invalid.

- Domain has a scheme :// (GH-15, GH-33)
- Domain contains spaces (GH-52)
- Domain contains double (GH-25, GH-36)

This is an hard decision to make, but as I explained more than one, the
purpose of this library is not to formally validate the syntax of a
domain or an URI.

The library expects the input to be a domain, and can't run all the
possible guesses and checks to guarantee the input. This is a
constraint that the caller must ensure. Entering the business of
validating URIs would make the maintenance of this library very

This is an example of a simple validation that could be used before
submitting the string for tokenisation.

def valid_uri?(name)
uri = URI.parse(name)
uri.host != nil

I don't exclude to add such filter in the future in the `#valid?`
method, may be as wrapper for the current `valid?` behaviour. But for
the time being, this library is not intended to formally validate URIs
or domains.

(closes GH-25, closes GH-36, closes GH-52)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment