Skip to content

Commit

Permalink
Drop libidn
Browse files Browse the repository at this point in the history
Instead, we use the pure Ruby IDNA solution in addressable.

Close #66.
  • Loading branch information
dentarg committed Nov 3, 2016
1 parent e9cc908 commit 057f675
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@ url.normalized.to_s # => "https://admin:correcthorsebatterystaple@www.

### Dependencies

The gem requires libidn.

sudo apt-get install libidn11 # Ubuntu
brew install libidn # OS X
Only the gems listed in the [Gem Specification](https://github.com/twingly/twingly-url/blob/master/twingly-url.gemspec).

## Development

Expand Down
2 changes: 0 additions & 2 deletions lib/twingly/url.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "addressable/uri"
require "addressable/idna/native"
require "public_suffix"

require_relative "public_suffix_list"
Expand All @@ -17,7 +16,6 @@ class URL
ERRORS_TO_EXTEND = [
Addressable::URI::InvalidURIError,
PublicSuffix::DomainInvalid,
IDN::Idna::IdnaError,
]

private_constant :ACCEPTED_SCHEMES
Expand Down
18 changes: 15 additions & 3 deletions spec/lib/twingly/url_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ def invalid_urls
# https://github.com/sporkmonger/addressable/issues/224
"http://some_site.net%C2",
"http://+%D5d.some_site.net",

# Triggers IDN::Idna::IdnaError: Output would be too large or too small (5)
"http://AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallumEst.com",
]
end

Expand All @@ -63,6 +60,21 @@ def valid_urls
"http://:@blog.twingly.com/",
"https://www.foo.ایران.ir/bar",
"https://www.foo.xn--mgba3a4f16a.ir/bar",

# The following URL triggers
#
# IDN::Idna::IdnaError: Output would be too large or too small (5)
#
# when used with Addressable and libidn (IDNA 2003)
# but considered valid with the pure Ruby IDNA solution in Addressable.
#
# This inconsistency has as been reported at
# https://github.com/sporkmonger/addressable/issues/239
#
# Long names like this will probably not resolv, see comments at
# https://github.com/twingly/twingly-url/issues/66#issuecomment-246349029
# but for now as addressable considers them valid, we do the same.
"http://AcinusFallumTrompetumNullunCreditumVisumEstAtCuadLongumEtCefallumEst.com",
]
end

Expand Down
1 change: 0 additions & 1 deletion twingly-url.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Gem::Specification.new do |s|

s.add_dependency "addressable", "~> 2.4", ">= 2.4.0"
s.add_dependency "public_suffix", "~> 2.0", ">= 2.0.2"
s.add_dependency "idn-ruby", "~> 0.1"

s.add_development_dependency "rake", "~> 10"
s.add_development_dependency "rspec", "~> 3"
Expand Down

0 comments on commit 057f675

Please sign in to comment.