-
Notifications
You must be signed in to change notification settings - Fork 1
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
domain, sld, trd (maybe others) can be nil #52
Comments
[5] pry(main)> uri = Addressable::URI.heuristic_parse("https://.com/path")
=> #<Addressable::URI:0x3ffeb1525144 URI:https://.com/path>
[6] pry(main)> uri.display_uri.host
=> ".com"
[7] pry(main)> PublicSuffix.parse(".com")
=> #<PublicSuffix::Domain:0x007ffd6329a1e0 @sld=nil, @tld="com", @trd=nil> |
[13] pry(main)> url = Twingly::URL.parse("https://.com/")
=> #<Twingly::URL:0x3fe1dcd5b828 https://.com/>
[14] pry(main)> cd url
[15] pry(#<Twingly::URL>):1> ls
Comparable#methods: < <= == > >= between?
Twingly::URL#methods: <=> domain host inspect normalized normalized_host normalized_path normalized_scheme origin path scheme sld tld to_s trd valid? without_scheme
self.methods: __pry__
instance variables: @addressable_uri @public_suffix_domain
locals: _ __ _dir_ _ex_ _file_ _in_ _out_ _pry_
[16] pry(#<Twingly::URL>):1> @public_suffix_domain
=> #<PublicSuffix::Domain:0x007fc3b9ab7190 @sld=nil, @tld="com", @trd=nil>
[17] pry(#<Twingly::URL>):1> @public_suffix_domain.domain
=> nil Strange :) |
[19] pry(#<Twingly::URL>):1> @public_suffix_domain.valid?
=> false
[20] pry(#<Twingly::URL>):1> @public_suffix_domain.valid_domain?
=> false |
Still think this case should count as a valid URL. $ curl -s -v `dig +short to`
* Rebuilt URL to: 216.74.32.107/
* Trying 216.74.32.107...
* Connected to 216.74.32.107 (216.74.32.107) port 80 (#0)
> GET / HTTP/1.1
> Host: 216.74.32.107
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 26 Oct 2015 16:33:40 GMT
< Server: Apache/2.2.22
< Last-Modified: Thu, 07 Nov 2013 06:30:52 GMT
< ETag: "6e01ed-b1-4ea90683f1f00"
< Accept-Ranges: bytes
< Content-Length: 177
< Vary: Accept-Encoding
< Content-Type: text/html
<
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
* Connection #0 to host 216.74.32.107 left intact |
.to is not the only one: http://blog.towo.eu/a-records-on-top-level-domains/ |
[4] pry(main)> Faraday.get "http://.to"
Faraday::ConnectionFailed: getaddrinfo: nodename nor servname provided, or not known
from /Users/dentarg/.rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:879:in `initialize' [5] pry(main)> Faraday.get "http://to"
Faraday::ConnectionFailed: getaddrinfo: nodename nor servname provided, or not known
from /Users/dentarg/.rubies/ruby-2.2.2/lib/ruby/2.2.0/net/http.rb:879:in `initialize' :-( |
More variants to consider. "http://[email protected]/" |
I'm okay with these being invalid URLs, just want us to solve this and not have the |
The best solution I can come up with is adding the following to raise Twingly::URL::Error::ParseError if addressable_uri.host.start_with?(".") || addressable_uri.host.end_with?(".") Works with all urls in this issue, but |
Another way is adding |
Maybe #74 will fix some (all) of these? |
Looks like it (disclaimer: I have not read the whole RFC :)) |
Rubys |
Ah, I see. Too bad. |
Another solution is that the URL must always have a second level domain, which makes all above urls invalid. raise Twingly::URL::Error::ParseError unless public_suffix_domain.sld |
close #52 Only added test for #trd since all other methods are tested in the "when given bad input" context.
This breaks our applications.
The text was updated successfully, but these errors were encountered: