addressable 2.3.7 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of addressable might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 531a87b0fdf38663665568cd7e14775397618665
4
- data.tar.gz: 88cc34caa61da92564835b0cf34a6e1ab8b7bb9c
3
+ metadata.gz: 73a7a5a0dfea976017780e3b434e97aa58216019
4
+ data.tar.gz: a708925a0882de04f840e9e54d279eb954775921
5
5
  SHA512:
6
- metadata.gz: c6e81bbd48d26f2df9b2291e2fa8210d467172696e6e8cf9007326eab8efb5b9687cc6db21d40e96005006b3f2ce0b25abdd2bb26143c5f6833156e1f01b6a97
7
- data.tar.gz: 05d5510dba6d0a581372c226bb5bc6d1e3f451b4a3b99e47f0ca26558368789706c5250dd3f755f0052a307f3e1562b343abfc33904b8cefd8d4a7f6f6f5e412
6
+ metadata.gz: c311a5594d7f1051df67287badef72551c52c6bc47598017099d5e8b5c2a9638144bcc6d635b418dfc1970e185cf31016ad54f681c7156d440223ef62f060bc5
7
+ data.tar.gz: 78527879654347fcf16be86684e1b37ca240c5a80d3baf2217cfdfb501cd6255de47a7cc8058c10e98e558b073981a27be06672f4dec8cf7d18e88a34609e6a1
@@ -1,3 +1,63 @@
1
+ # Addressable 2.7.0
2
+ - added `:compacted` flag to `normalized_query`
3
+ - `heuristic_parse` handles `mailto:` more intuitively
4
+ - refactored validation to use a prepended module
5
+ - dropped explicit support for JRuby 9.0.5.0
6
+ - compatibility w/ public_suffix 4.x
7
+ - performance improvements
8
+
9
+ # Addressable 2.6.0
10
+ - added `tld=` method to allow assignment to the public suffix
11
+ - most `heuristic_parse` patterns are now case-insensitive
12
+ - `heuristic_parse` handles more `file://` URI variations
13
+ - fixes bug in `heuristic_parse` when uri starts with digit
14
+ - fixes bug in `request_uri=` with query strings
15
+ - fixes template issues with `nil` and `?` operator
16
+ - `frozen_string_literal` pragmas added
17
+ - minor performance improvements in regexps
18
+ - fixes to eliminate warnings
19
+
20
+ # Addressable 2.5.2
21
+ - better support for frozen string literals
22
+ - fixed bug w/ uppercase characters in scheme
23
+ - IDNA errors w/ emoji URLs
24
+ - compatibility w/ public_suffix 3.x
25
+
26
+ # Addressable 2.5.1
27
+ - allow unicode normalization to be disabled for URI Template expansion
28
+ - removed duplicate test
29
+
30
+ # Addressable 2.5.0
31
+ - dropping support for Ruby 1.9
32
+ - adding support for Ruby 2.4 preview
33
+ - add support for public suffixes and tld; first runtime dependency
34
+ - hostname escaping should match RFC; underscores in hostnames no longer escaped
35
+ - paths beginning with // and missing an authority are now considered invalid
36
+ - validation now also takes place after setting a path
37
+ - handle backslashes in authority more like a browser for `heuristic_parse`
38
+ - unescaped backslashes in host now raise an `InvalidURIError`
39
+ - `merge!`, `join!`, `omit!` and `normalize!` don't disable deferred validation
40
+ - `heuristic_parse` now trims whitespace before parsing
41
+ - host parts longer than 63 bytes will be ignored and not passed to libidn
42
+ - normalized values always encoded as UTF-8
43
+
44
+ # Addressable 2.4.0
45
+ - support for 1.8.x dropped
46
+ - double quotes in a host now raises an error
47
+ - newlines in host will no longer get unescaped during normalization
48
+ - stricter handling of bogus scheme values
49
+ - stricter handling of encoded port values
50
+ - calling `require 'addressable'` will now load both the URI and Template files
51
+ - assigning to the `hostname` component with an `IPAddr` object is now supported
52
+ - assigning to the `origin` component is now supported
53
+ - fixed minor bug where an exception would be thrown for a missing ACE suffix
54
+ - better partial expansion of URI templates
55
+
56
+ # Addressable 2.3.8
57
+ - fix warnings
58
+ - update dependency gems
59
+ - support for 1.8.x officially deprecated
60
+
1
61
  # Addressable 2.3.7
2
62
  - fix scenario in which invalid URIs don't get an exception until inspected
3
63
  - handle hostnames with two adjacent periods correctly
data/Gemfile CHANGED
@@ -1,26 +1,32 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gemspec
4
+
5
+ group :test do
6
+ gem 'rspec', '~> 3.8'
7
+ gem 'rspec-its', '~> 1.3'
8
+ end
9
+
3
10
  group :development do
4
- gem 'launchy'
5
- gem 'yard'
11
+ gem 'launchy', '~> 2.4', '>= 2.4.3'
6
12
  gem 'redcarpet', :platform => :mri_19
7
- gem 'rubyforge'
13
+ gem 'yard'
8
14
  end
9
15
 
10
16
  group :test, :development do
11
- gem 'coveralls', :require => false
12
- end
13
-
14
- gem 'idn', :platform => :mri_18
15
- gem 'idn-ruby', :platform => :mri_19
17
+ gem 'rake', '> 10.0', '< 12'
18
+ gem 'simplecov', :require => false
19
+ gem 'coveralls', :require => false, :platforms => [
20
+ :ruby_20, :ruby_21, :ruby_22, :ruby_23
21
+ ]
22
+ # Used to test compatibility.
23
+ gem 'rack-mount', git: 'https://github.com/sporkmonger/rack-mount.git', require: 'rack/mount'
16
24
 
17
- platforms :ruby_18 do
18
- gem 'mime-types', '~> 1.25'
19
- gem 'rest-client', '~> 1.6.0'
25
+ if RUBY_VERSION.start_with?('2.0', '2.1')
26
+ gem 'rack', '< 2', :require => false
27
+ else
28
+ gem 'rack', :require => false
29
+ end
20
30
  end
21
31
 
22
- platforms :rbx do
23
- gem 'rubysl-openssl', '2.1.0'
24
- end
25
-
26
- gemspec
32
+ gem 'idn-ruby', :platform => [:mri_20, :mri_21, :mri_22, :mri_23, :mri_24]
data/README.md CHANGED
@@ -1,30 +1,29 @@
1
1
  # Addressable
2
2
 
3
3
  <dl>
4
- <dt>Homepage</dt><dd><a href="http://addressable.rubyforge.org/">addressable.rubyforge.org</a></dd>
4
+ <dt>Homepage</dt><dd><a href="https://github.com/sporkmonger/addressable">github.com/sporkmonger/addressable</a></dd>
5
5
  <dt>Author</dt><dd><a href="mailto:bob@sporkmonger.com">Bob Aman</a></dd>
6
- <dt>Copyright</dt><dd>Copyright © 2006-2014 Bob Aman</dd>
6
+ <dt>Copyright</dt><dd>Copyright © Bob Aman</dd>
7
7
  <dt>License</dt><dd>Apache 2.0</dd>
8
8
  </dl>
9
9
 
10
10
  [![Gem Version](http://img.shields.io/gem/dt/addressable.svg)][gem]
11
- [![Build Status](https://secure.travis-ci.org/sporkmonger/addressable.png?branch=master)][travis]
12
- [![Dependency Status](https://gemnasium.com/sporkmonger/addressable.png?travis)][gemnasium]
11
+ [![Build Status](https://secure.travis-ci.org/sporkmonger/addressable.svg?branch=master)][travis]
13
12
  [![Test Coverage Status](https://img.shields.io/coveralls/sporkmonger/addressable.svg)][coveralls]
14
13
  [![Documentation Coverage Status](http://inch-ci.org/github/sporkmonger/addressable.svg?branch=master)][inch]
15
- [![Gittip Donate](http://img.shields.io/gittip/sporkmonger.png)](https://www.gittip.com/sporkmonger/ "Support Open Source Development w/ Gittip")
16
14
 
17
15
  [gem]: https://rubygems.org/gems/addressable
18
16
  [travis]: http://travis-ci.org/sporkmonger/addressable
19
- [gemnasium]: https://gemnasium.com/sporkmonger/addressable
20
17
  [coveralls]: https://coveralls.io/r/sporkmonger/addressable
21
18
  [inch]: http://inch-ci.org/github/sporkmonger/addressable
22
19
 
23
20
  # Description
24
21
 
25
- Addressable is a replacement for the URI implementation that is part of
26
- Ruby's standard library. It more closely conforms to RFC 3986, RFC 3987, and
27
- RFC 6570 (level 4), providing support for IRIs and URI templates.
22
+ Addressable is an alternative implementation to the URI implementation
23
+ that is part of Ruby's standard library. It is flexible, offers heuristic
24
+ parsing, and additionally provides extensive support for IRIs and URI templates.
25
+
26
+ Addressable closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4).
28
27
 
29
28
  # Reference
30
29
 
@@ -59,7 +58,7 @@ For more details, see [RFC 6570](https://www.rfc-editor.org/rfc/rfc6570.txt).
59
58
 
60
59
  require "addressable/template"
61
60
 
62
- template = Addressable::Template.new("http://example.com/{?query*}/")
61
+ template = Addressable::Template.new("http://example.com/{?query*}")
63
62
  template.expand({
64
63
  "query" => {
65
64
  'foo' => 'bar',
@@ -68,12 +67,12 @@ template.expand({
68
67
  })
69
68
  #=> #<Addressable::URI:0xc9d95c URI:http://example.com/?foo=bar&color=red>
70
69
 
71
- template = Addressable::Template.new("http://example.com/{?one,two,three}/")
70
+ template = Addressable::Template.new("http://example.com/{?one,two,three}")
72
71
  template.partial_expand({"one" => "1", "three" => 3}).pattern
73
72
  #=> "http://example.com/?one=1{&two}&three=3"
74
73
 
75
74
  template = Addressable::Template.new(
76
- "http://{host}{/segments}/{?one,two,bogus}{#fragment}"
75
+ "http://{host}{/segments*}/{?one,two,bogus}{#fragment}"
77
76
  )
78
77
  uri = Addressable::URI.parse(
79
78
  "http://example.com/a/b/c/?one=1&two=2#foo"
@@ -92,7 +91,7 @@ template.extract(uri)
92
91
  # Install
93
92
 
94
93
  ```console
95
- $ sudo gem install addressable
94
+ $ gem install addressable
96
95
  ```
97
96
 
98
97
  You may optionally turn on native IDN support by installing libidn and the
@@ -100,6 +99,23 @@ idn gem:
100
99
 
101
100
  ```console
102
101
  $ sudo apt-get install idn # Debian/Ubuntu
103
- $ sudo brew install libidn # OS X
104
- $ sudo gem install idn-ruby
102
+ $ brew install libidn # OS X
103
+ $ gem install idn-ruby
104
+ ```
105
+
106
+ # Semantic Versioning
107
+
108
+ This project uses [Semantic Versioning](https://semver.org/). You can (and should) specify your
109
+ dependency using a pessimistic version constraint covering the major and minor
110
+ values:
111
+
112
+ ```ruby
113
+ spec.add_dependency 'addressable', '~> 2.5'
114
+ ```
115
+
116
+ If you need a specific bug fix, you can also specify minimum tiny versions
117
+ without preventing updates to the latest minor release:
118
+
119
+ ```ruby
120
+ spec.add_dependency 'addressable', '~> 2.3', '>= 2.3.7'
105
121
  ```
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rubygems'
2
4
  require 'rake'
3
5
 
@@ -10,25 +12,20 @@ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
10
12
 
11
13
  RELEASE_NAME = "REL #{PKG_VERSION}"
12
14
 
13
- RUBY_FORGE_PROJECT = PKG_NAME
14
- RUBY_FORGE_USER = "sporkmonger"
15
- RUBY_FORGE_PATH = "/var/www/gforge-projects/#{RUBY_FORGE_PROJECT}"
16
- RUBY_FORGE_URL = "http://#{RUBY_FORGE_PROJECT}.rubyforge.org/"
17
-
18
15
  PKG_SUMMARY = "URI Implementation"
19
16
  PKG_DESCRIPTION = <<-TEXT
20
- Addressable is a replacement for the URI implementation that is part of
21
- Ruby's standard library. It more closely conforms to the relevant RFCs and
22
- adds support for IRIs and URI templates.
17
+ Addressable is an alternative implementation to the URI implementation that is
18
+ part of Ruby's standard library. It is flexible, offers heuristic parsing, and
19
+ additionally provides extensive support for IRIs and URI templates.
23
20
  TEXT
24
21
 
25
22
  PKG_FILES = FileList[
26
23
  "lib/**/*", "spec/**/*", "vendor/**/*", "data/**/*",
27
- "tasks/**/*", "website/**/*",
24
+ "tasks/**/*",
28
25
  "[A-Z]*", "Rakefile"
29
- ].exclude(/database\.yml/).exclude(/Gemfile\.lock/).exclude(/[_\.]git$/)
26
+ ].exclude(/pkg/).exclude(/database\.yml/).
27
+ exclude(/Gemfile\.lock/).exclude(/[_\.]git$/)
30
28
 
31
- RCOV_ENABLED = (RUBY_PLATFORM != "java" && RUBY_VERSION =~ /^1\.8/)
32
29
  task :default => "spec"
33
30
 
34
31
  WINDOWS = (RUBY_PLATFORM =~ /mswin|win32|mingw|bccwin|cygwin/) rescue false
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'addressable/uri'
4
+ require 'addressable/template'
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # encoding:utf-8
2
4
  #--
3
- # Copyright (C) 2006-2013 Bob Aman
5
+ # Copyright (C) Bob Aman
4
6
  #
5
7
  # Licensed under the Apache License, Version 2.0 (the "License");
6
8
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # encoding:utf-8
2
4
  #--
3
- # Copyright (C) 2006-2013 Bob Aman
5
+ # Copyright (C) Bob Aman
4
6
  #
5
7
  # Licensed under the Apache License, Version 2.0 (the "License");
6
8
  # you may not use this file except in compliance with the License.
@@ -34,8 +36,10 @@ module Addressable
34
36
 
35
37
  def self.to_ascii(value)
36
38
  value.to_s.split('.', -1).map do |segment|
37
- if segment.size > 0
38
- IDN::Idna.toASCII(segment)
39
+ if segment.size > 0 && segment.size < 64
40
+ IDN::Idna.toASCII(segment, IDN::Idna::ALLOW_UNASSIGNED)
41
+ elsif segment.size >= 64
42
+ segment
39
43
  else
40
44
  ''
41
45
  end
@@ -44,8 +48,10 @@ module Addressable
44
48
 
45
49
  def self.to_unicode(value)
46
50
  value.to_s.split('.', -1).map do |segment|
47
- if segment.size > 0
48
- IDN::Idna.toUnicode(segment)
51
+ if segment.size > 0 && segment.size < 64
52
+ IDN::Idna.toUnicode(segment, IDN::Idna::ALLOW_UNASSIGNED)
53
+ elsif segment.size >= 64
54
+ segment
49
55
  else
50
56
  ''
51
57
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # encoding:utf-8
2
4
  #--
3
- # Copyright (C) 2006-2013 Bob Aman
5
+ # Copyright (C) Bob Aman
4
6
  #
5
7
  # Licensed under the Apache License, Version 2.0 (the "License");
6
8
  # you may not use this file except in compliance with the License.
@@ -93,8 +95,13 @@ module Addressable
93
95
  input = input.to_s unless input.is_a?(String)
94
96
  parts = input.split('.')
95
97
  parts.map! do |part|
96
- if part =~ /^#{ACE_PREFIX}/
97
- punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1])
98
+ if part =~ /^#{ACE_PREFIX}(.+)/
99
+ begin
100
+ punycode_decode(part[/^#{ACE_PREFIX}(.+)/, 1])
101
+ rescue Addressable::IDNA::PunycodeBadInput
102
+ # toUnicode is explicitly defined as never-fails by the spec
103
+ part
104
+ end
98
105
  else
99
106
  part
100
107
  end
@@ -128,7 +135,7 @@ module Addressable
128
135
  unpacked.map! { |codepoint| lookup_unicode_lowercase(codepoint) }
129
136
  return unpacked.pack("U*")
130
137
  end
131
- (class <<self; private :unicode_downcase; end)
138
+ private_class_method :unicode_downcase
132
139
 
133
140
  def self.unicode_compose(unpacked)
134
141
  unpacked_result = []
@@ -141,22 +148,19 @@ module Addressable
141
148
  starter_cc = 256 if starter_cc != 0
142
149
  for i in 1...length
143
150
  ch = unpacked[i]
144
- cc = lookup_unicode_combining_class(ch)
145
151
 
146
152
  if (starter_cc == 0 &&
147
153
  (composite = unicode_compose_pair(starter, ch)) != nil)
148
154
  starter = composite
149
- startercc = lookup_unicode_combining_class(composite)
150
155
  else
151
156
  unpacked_result << starter
152
157
  starter = ch
153
- startercc = cc
154
158
  end
155
159
  end
156
160
  unpacked_result << starter
157
161
  return unpacked_result
158
162
  end
159
- (class <<self; private :unicode_compose; end)
163
+ private_class_method :unicode_compose
160
164
 
161
165
  def self.unicode_compose_pair(ch_one, ch_two)
162
166
  if ch_one >= HANGUL_LBASE && ch_one < HANGUL_LBASE + HANGUL_LCOUNT &&
@@ -175,7 +179,6 @@ module Addressable
175
179
 
176
180
  p = []
177
181
  ucs4_to_utf8 = lambda do |ch|
178
- # For some reason, rcov likes to drop BUS errors here.
179
182
  if ch < 128
180
183
  p << ch
181
184
  elsif ch < 2048
@@ -211,7 +214,7 @@ module Addressable
211
214
 
212
215
  return lookup_unicode_composition(p)
213
216
  end
214
- (class <<self; private :unicode_compose_pair; end)
217
+ private_class_method :unicode_compose_pair
215
218
 
216
219
  def self.unicode_sort_canonical(unpacked)
217
220
  unpacked = unpacked.dup
@@ -235,7 +238,7 @@ module Addressable
235
238
  end
236
239
  return unpacked
237
240
  end
238
- (class <<self; private :unicode_sort_canonical; end)
241
+ private_class_method :unicode_sort_canonical
239
242
 
240
243
  def self.unicode_decompose(unpacked)
241
244
  unpacked_result = []
@@ -256,7 +259,7 @@ module Addressable
256
259
  end
257
260
  return unpacked_result
258
261
  end
259
- (class <<self; private :unicode_decompose; end)
262
+ private_class_method :unicode_decompose
260
263
 
261
264
  def self.unicode_decompose_hangul(codepoint)
262
265
  sindex = codepoint - HANGUL_SBASE;
@@ -273,7 +276,7 @@ module Addressable
273
276
  end
274
277
  return l, v, t
275
278
  end
276
- (class <<self; private :unicode_decompose_hangul; end)
279
+ private_class_method :unicode_decompose_hangul
277
280
 
278
281
  def self.lookup_unicode_combining_class(codepoint)
279
282
  codepoint_data = UNICODE_DATA[codepoint]
@@ -281,14 +284,14 @@ module Addressable
281
284
  (codepoint_data[UNICODE_DATA_COMBINING_CLASS] || 0) :
282
285
  0)
283
286
  end
284
- (class <<self; private :lookup_unicode_combining_class; end)
287
+ private_class_method :lookup_unicode_combining_class
285
288
 
286
289
  def self.lookup_unicode_compatibility(codepoint)
287
290
  codepoint_data = UNICODE_DATA[codepoint]
288
291
  (codepoint_data ?
289
292
  codepoint_data[UNICODE_DATA_COMPATIBILITY] : nil)
290
293
  end
291
- (class <<self; private :lookup_unicode_compatibility; end)
294
+ private_class_method :lookup_unicode_compatibility
292
295
 
293
296
  def self.lookup_unicode_lowercase(codepoint)
294
297
  codepoint_data = UNICODE_DATA[codepoint]
@@ -296,12 +299,12 @@ module Addressable
296
299
  (codepoint_data[UNICODE_DATA_LOWERCASE] || codepoint) :
297
300
  codepoint)
298
301
  end
299
- (class <<self; private :lookup_unicode_lowercase; end)
302
+ private_class_method :lookup_unicode_lowercase
300
303
 
301
304
  def self.lookup_unicode_composition(unpacked)
302
305
  return COMPOSITION_TABLE[unpacked]
303
306
  end
304
- (class <<self; private :lookup_unicode_composition; end)
307
+ private_class_method :lookup_unicode_composition
305
308
 
306
309
  HANGUL_SBASE = 0xac00
307
310
  HANGUL_LBASE = 0x1100
@@ -338,7 +341,7 @@ module Addressable
338
341
  end
339
342
 
340
343
  COMPOSITION_TABLE = {}
341
- for codepoint, data in UNICODE_DATA
344
+ UNICODE_DATA.each do |codepoint, data|
342
345
  canonical = data[UNICODE_DATA_CANONICAL]
343
346
  exclusion = data[UNICODE_DATA_EXCLUSION]
344
347
 
@@ -488,7 +491,7 @@ module Addressable
488
491
  outlen.times do |j|
489
492
  c = output[j]
490
493
  unless c >= 0 && c <= 127
491
- raise Exception, "Invalid output char."
494
+ raise StandardError, "Invalid output char."
492
495
  end
493
496
  unless PUNYCODE_PRINT_ASCII[c]
494
497
  raise PunycodeBadInput, "Input is invalid."
@@ -497,7 +500,7 @@ module Addressable
497
500
 
498
501
  output[0..outlen].map { |x| x.chr }.join("").sub(/\0+\z/, "")
499
502
  end
500
- (class <<self; private :punycode_encode; end)
503
+ private_class_method :punycode_encode
501
504
 
502
505
  def self.punycode_decode(punycode)
503
506
  input = []
@@ -619,22 +622,22 @@ module Addressable
619
622
 
620
623
  output.pack("U*")
621
624
  end
622
- (class <<self; private :punycode_decode; end)
625
+ private_class_method :punycode_decode
623
626
 
624
627
  def self.punycode_basic?(codepoint)
625
628
  codepoint < 0x80
626
629
  end
627
- (class <<self; private :punycode_basic?; end)
630
+ private_class_method :punycode_basic?
628
631
 
629
632
  def self.punycode_delimiter?(codepoint)
630
633
  codepoint == PUNYCODE_DELIMITER
631
634
  end
632
- (class <<self; private :punycode_delimiter?; end)
635
+ private_class_method :punycode_delimiter?
633
636
 
634
637
  def self.punycode_encode_digit(d)
635
638
  d + 22 + 75 * ((d < 26) ? 1 : 0)
636
639
  end
637
- (class <<self; private :punycode_encode_digit; end)
640
+ private_class_method :punycode_encode_digit
638
641
 
639
642
  # Returns the numeric value of a basic codepoint
640
643
  # (for use in representing integers) in the range 0 to
@@ -650,7 +653,7 @@ module Addressable
650
653
  PUNYCODE_BASE
651
654
  end
652
655
  end
653
- (class <<self; private :punycode_decode_digit; end)
656
+ private_class_method :punycode_decode_digit
654
657
 
655
658
  # Bias adaptation method
656
659
  def self.punycode_adapt(delta, numpoints, firsttime)
@@ -667,7 +670,7 @@ module Addressable
667
670
 
668
671
  k + (difference + 1) * delta / (delta + PUNYCODE_SKEW)
669
672
  end
670
- (class <<self; private :punycode_adapt; end)
673
+ private_class_method :punycode_adapt
671
674
  end
672
675
  # :startdoc:
673
676
  end