activesupport 5.2.2.1 → 5.2.5

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

Potentially problematic release.


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

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8f85b76a4258720d6ec697ba09ca8417c9898bc8b85cde9533f1ea8017d4373d
4
- data.tar.gz: b74ac1958cd6df321c1975439ddc1511f8c624498804e83fc15f16691b7d2683
3
+ metadata.gz: 7e0fa29c7295e4a4402a7e6c2db46a0179f35b3b68125888a6cc191b186af251
4
+ data.tar.gz: b1683c3540effb16dd44128bb9f0986388f21ff777e0b3a44eae779160aaf45f
5
5
  SHA512:
6
- metadata.gz: 9f81fa3dff61091986dacb3a5d1aa407d51056be96fdeff5a284395c1b7b115992ae56b9ac880d7fc5f790f0e8e67f71af045ccc84d7362dfedf091598e57dc9
7
- data.tar.gz: 4026828e4898d47ffc43ca05b4d558aa5fd5d27247f87d0c750021b684bceccff274d4d49d1c8e1839a0af17f3a8006f0fc78214e57173f1aea5465326f7474a
6
+ metadata.gz: 6b323c40a81203c83c422534df283d010d1f544787277cf914008353a8c5437dfba3b688176512a197af31df312c5a0e56f06b7fa19578ba4ff78189fd05041b
7
+ data.tar.gz: 3ad31799a6a8f24dabac77889a5d0b5e2c6f4fe818426abe4aa98a26a307159cf79ff03eb44af5bf3ea84efd7c6604fbe2240366c98cc3f0575fc7fe628132f4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,94 @@
1
+ ## Rails 5.2.5 (March 26, 2021) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 5.2.4.5 (February 10, 2021) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 5.2.4.4 (September 09, 2020) ##
12
+
13
+ * No changes.
14
+
15
+
16
+ ## Rails 5.2.4.3 (May 18, 2020) ##
17
+
18
+ * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
19
+
20
+ * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
21
+
22
+ ## Rails 5.2.4.2 (March 19, 2020) ##
23
+
24
+ * No changes.
25
+
26
+
27
+ ## Rails 5.2.4.1 (December 18, 2019) ##
28
+
29
+ * No changes.
30
+
31
+
32
+ ## Rails 5.2.4 (November 27, 2019) ##
33
+
34
+ * Make ActiveSupport::Logger Fiber-safe. Fixes #36752.
35
+
36
+ Use `Fiber.current.__id__` in `ActiveSupport::Logger#local_level=` in order
37
+ to make log level local to Ruby Fibers in addition to Threads.
38
+
39
+ Example:
40
+
41
+ logger = ActiveSupport::Logger.new(STDOUT)
42
+ logger.level = 1
43
+ p "Main is debug? #{logger.debug?}"
44
+
45
+ Fiber.new {
46
+ logger.local_level = 0
47
+ p "Thread is debug? #{logger.debug?}"
48
+ }.resume
49
+
50
+ p "Main is debug? #{logger.debug?}"
51
+
52
+ Before:
53
+
54
+ Main is debug? false
55
+ Thread is debug? true
56
+ Main is debug? true
57
+
58
+ After:
59
+
60
+ Main is debug? false
61
+ Thread is debug? true
62
+ Main is debug? false
63
+
64
+ *Alexander Varnin*
65
+
66
+
67
+ ## Rails 5.2.3 (March 27, 2019) ##
68
+
69
+ * Add `ActiveSupport::HashWithIndifferentAccess#assoc`.
70
+
71
+ `assoc` can now be called with either a string or a symbol.
72
+
73
+ *Stefan Schüßler*
74
+
75
+ * Fix `String#safe_constantize` throwing a `LoadError` for incorrectly cased constant references.
76
+
77
+ *Keenan Brock*
78
+
79
+ * Allow Range#=== and Range#cover? on Range
80
+
81
+ `Range#cover?` can now accept a range argument like `Range#include?` and
82
+ `Range#===`. `Range#===` works correctly on Ruby 2.6. `Range#include?` is moved
83
+ into a new file, with these two methods.
84
+
85
+ *utilum*
86
+
87
+ * If the same block is `included` multiple times for a Concern, an exception is no longer raised.
88
+
89
+ *Mark J. Titorenko*, *Vlad Bokov*
90
+
91
+
1
92
  ## Rails 5.2.2.1 (March 11, 2019) ##
2
93
 
3
94
  * No changes.
@@ -28,14 +28,6 @@ module ActiveSupport
28
28
  # Provide support for raw values in the local cache strategy.
29
29
  module LocalCacheWithRaw # :nodoc:
30
30
  private
31
- def read_entry(key, options)
32
- entry = super
33
- if options[:raw] && local_cache && entry
34
- entry = deserialize_entry(entry.value)
35
- end
36
- entry
37
- end
38
-
39
31
  def write_entry(key, entry, options)
40
32
  if options[:raw] && local_cache
41
33
  raw_entry = Entry.new(entry.value.to_s)
@@ -189,9 +181,8 @@ module ActiveSupport
189
181
  key
190
182
  end
191
183
 
192
- def deserialize_entry(raw_value)
193
- if raw_value
194
- entry = Marshal.load(raw_value) rescue raw_value
184
+ def deserialize_entry(entry)
185
+ if entry
195
186
  entry.is_a?(Entry) ? entry : Entry.new(entry)
196
187
  end
197
188
  end
@@ -70,14 +70,6 @@ module ActiveSupport
70
70
  # Support raw values in the local cache strategy.
71
71
  module LocalCacheWithRaw # :nodoc:
72
72
  private
73
- def read_entry(key, options)
74
- entry = super
75
- if options[:raw] && local_cache && entry
76
- entry = deserialize_entry(entry.value)
77
- end
78
- entry
79
- end
80
-
81
73
  def write_entry(key, entry, options)
82
74
  if options[:raw] && local_cache
83
75
  raw_entry = Entry.new(serialize_entry(entry, raw: true))
@@ -328,7 +320,8 @@ module ActiveSupport
328
320
  # Read an entry from the cache.
329
321
  def read_entry(key, options = nil)
330
322
  failsafe :read_entry do
331
- deserialize_entry redis.with { |c| c.get(key) }
323
+ raw = options && options.fetch(:raw, false)
324
+ deserialize_entry(redis.with { |c| c.get(key) }, raw: raw)
332
325
  end
333
326
  end
334
327
 
@@ -343,6 +336,7 @@ module ActiveSupport
343
336
  def read_multi_mget(*names)
344
337
  options = names.extract_options!
345
338
  options = merged_options(options)
339
+ raw = options && options.fetch(:raw, false)
346
340
 
347
341
  keys = names.map { |name| normalize_key(name, options) }
348
342
 
@@ -352,7 +346,7 @@ module ActiveSupport
352
346
 
353
347
  names.zip(values).each_with_object({}) do |(name, value), results|
354
348
  if value
355
- entry = deserialize_entry(value)
349
+ entry = deserialize_entry(value, raw: raw)
356
350
  unless entry.nil? || entry.expired? || entry.mismatched?(normalize_version(name, options))
357
351
  results[name] = entry.value
358
352
  end
@@ -421,9 +415,20 @@ module ActiveSupport
421
415
  end
422
416
  end
423
417
 
424
- def deserialize_entry(serialized_entry)
418
+ def deserialize_entry(serialized_entry, raw:)
425
419
  if serialized_entry
426
420
  entry = Marshal.load(serialized_entry) rescue serialized_entry
421
+
422
+ written_raw = serialized_entry.equal?(entry)
423
+ if raw != written_raw
424
+ ActiveSupport::Deprecation.warn(<<-MSG.squish)
425
+ Using a different value for the raw option when reading and writing
426
+ to a cache key is deprecated for :redis_cache_store and Rails 6.0
427
+ will stop automatically detecting the format when reading to avoid
428
+ marshal loading untrusted raw strings.
429
+ MSG
430
+ end
431
+
427
432
  entry.is_a?(Entry) ? entry : Entry.new(entry)
428
433
  end
429
434
  end
@@ -125,9 +125,13 @@ module ActiveSupport
125
125
 
126
126
  def included(base = nil, &block)
127
127
  if base.nil?
128
- raise MultipleIncludedBlocks if instance_variable_defined?(:@_included_block)
129
-
130
- @_included_block = block
128
+ if instance_variable_defined?(:@_included_block)
129
+ if @_included_block.source_location != block.source_location
130
+ raise MultipleIncludedBlocks
131
+ end
132
+ else
133
+ @_included_block = block
134
+ end
131
135
  else
132
136
  super
133
137
  end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support/core_ext/digest/uuid"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/range/conversions"
4
- require "active_support/core_ext/range/include_range"
4
+ require "active_support/core_ext/range/compare_range"
5
5
  require "active_support/core_ext/range/include_time_with_zone"
6
6
  require "active_support/core_ext/range/overlaps"
7
7
  require "active_support/core_ext/range/each"
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveSupport
4
+ module CompareWithRange #:nodoc:
5
+ # Extends the default Range#=== to support range comparisons.
6
+ # (1..5) === (1..5) # => true
7
+ # (1..5) === (2..3) # => true
8
+ # (1..5) === (2..6) # => false
9
+ #
10
+ # The native Range#=== behavior is untouched.
11
+ # ('a'..'f') === ('c') # => true
12
+ # (5..9) === (11) # => false
13
+ def ===(value)
14
+ if value.is_a?(::Range)
15
+ # 1...10 includes 1..9 but it does not include 1..10.
16
+ operator = exclude_end? && !value.exclude_end? ? :< : :<=
17
+ super(value.first) && value.last.send(operator, last)
18
+ else
19
+ super
20
+ end
21
+ end
22
+
23
+ # Extends the default Range#include? to support range comparisons.
24
+ # (1..5).include?(1..5) # => true
25
+ # (1..5).include?(2..3) # => true
26
+ # (1..5).include?(2..6) # => false
27
+ #
28
+ # The native Range#include? behavior is untouched.
29
+ # ('a'..'f').include?('c') # => true
30
+ # (5..9).include?(11) # => false
31
+ def include?(value)
32
+ if value.is_a?(::Range)
33
+ # 1...10 includes 1..9 but it does not include 1..10.
34
+ operator = exclude_end? && !value.exclude_end? ? :< : :<=
35
+ super(value.first) && value.last.send(operator, last)
36
+ else
37
+ super
38
+ end
39
+ end
40
+
41
+ # Extends the default Range#cover? to support range comparisons.
42
+ # (1..5).cover?(1..5) # => true
43
+ # (1..5).cover?(2..3) # => true
44
+ # (1..5).cover?(2..6) # => false
45
+ #
46
+ # The native Range#cover? behavior is untouched.
47
+ # ('a'..'f').cover?('c') # => true
48
+ # (5..9).cover?(11) # => false
49
+ def cover?(value)
50
+ if value.is_a?(::Range)
51
+ # 1...10 covers 1..9 but it does not cover 1..10.
52
+ operator = exclude_end? && !value.exclude_end? ? :< : :<=
53
+ super(value.first) && value.last.send(operator, last)
54
+ else
55
+ super
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ Range.prepend(ActiveSupport::CompareWithRange)
@@ -1,25 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ActiveSupport
4
- module IncludeWithRange #:nodoc:
5
- # Extends the default Range#include? to support range comparisons.
6
- # (1..5).include?(1..5) # => true
7
- # (1..5).include?(2..3) # => true
8
- # (1..5).include?(2..6) # => false
9
- #
10
- # The native Range#include? behavior is untouched.
11
- # ('a'..'f').include?('c') # => true
12
- # (5..9).include?(11) # => false
13
- def include?(value)
14
- if value.is_a?(::Range)
15
- # 1...10 includes 1..9 but it does not include 1..10.
16
- operator = exclude_end? && !value.exclude_end? ? :< : :<=
17
- super(value.first) && value.last.send(operator, last)
18
- else
19
- super
20
- end
21
- end
22
- end
23
- end
24
-
25
- Range.prepend(ActiveSupport::IncludeWithRange)
3
+ require "active_support/core_ext/range/compare_range"
@@ -53,27 +53,37 @@ module ActiveSupport
53
53
  options = method_names.extract_options!
54
54
  deprecator = options.delete(:deprecator) || self
55
55
  method_names += options.keys
56
+ mod = Module.new
56
57
 
57
58
  method_names.each do |method_name|
58
- aliased_method, punctuation = method_name.to_s.sub(/([?!=])$/, ""), $1
59
- with_method = "#{aliased_method}_with_deprecation#{punctuation}"
60
- without_method = "#{aliased_method}_without_deprecation#{punctuation}"
59
+ if target_module.method_defined?(method_name) || target_module.private_method_defined?(method_name)
60
+ aliased_method, punctuation = method_name.to_s.sub(/([?!=])$/, ""), $1
61
+ with_method = "#{aliased_method}_with_deprecation#{punctuation}"
62
+ without_method = "#{aliased_method}_without_deprecation#{punctuation}"
61
63
 
62
- target_module.send(:define_method, with_method) do |*args, &block|
63
- deprecator.deprecation_warning(method_name, options[method_name])
64
- send(without_method, *args, &block)
65
- end
64
+ target_module.send(:define_method, with_method) do |*args, &block|
65
+ deprecator.deprecation_warning(method_name, options[method_name])
66
+ send(without_method, *args, &block)
67
+ end
66
68
 
67
- target_module.send(:alias_method, without_method, method_name)
68
- target_module.send(:alias_method, method_name, with_method)
69
+ target_module.send(:alias_method, without_method, method_name)
70
+ target_module.send(:alias_method, method_name, with_method)
69
71
 
70
- case
71
- when target_module.protected_method_defined?(without_method)
72
- target_module.send(:protected, method_name)
73
- when target_module.private_method_defined?(without_method)
74
- target_module.send(:private, method_name)
72
+ case
73
+ when target_module.protected_method_defined?(without_method)
74
+ target_module.send(:protected, method_name)
75
+ when target_module.private_method_defined?(without_method)
76
+ target_module.send(:private, method_name)
77
+ end
78
+ else
79
+ mod.send(:define_method, method_name) do |*args, &block|
80
+ deprecator.deprecation_warning(method_name, options[method_name])
81
+ super(*args, &block)
82
+ end
75
83
  end
76
84
  end
85
+
86
+ target_module.prepend(mod) unless mod.instance_methods(false).empty?
77
87
  end
78
88
  end
79
89
  end
@@ -183,15 +183,15 @@ module ActiveSupport
183
183
  #
184
184
  def build(value)
185
185
  parts = {}
186
- remainder = value.to_f
186
+ remainder = value.round(9)
187
187
 
188
188
  PARTS.each do |part|
189
189
  unless part == :seconds
190
190
  part_in_seconds = PARTS_IN_SECONDS[part]
191
191
  parts[part] = remainder.div(part_in_seconds)
192
- remainder = (remainder % part_in_seconds).round(9)
192
+ remainder %= part_in_seconds
193
193
  end
194
- end
194
+ end unless value == 0
195
195
 
196
196
  parts[:seconds] = remainder
197
197
 
@@ -210,7 +210,7 @@ module ActiveSupport
210
210
  def initialize(value, parts) #:nodoc:
211
211
  @value, @parts = value, parts.to_h
212
212
  @parts.default = 0
213
- @parts.reject! { |k, v| v.zero? }
213
+ @parts.reject! { |k, v| v.zero? } unless value == 0
214
214
  end
215
215
 
216
216
  def coerce(other) #:nodoc:
@@ -400,8 +400,14 @@ module ActiveSupport
400
400
  private
401
401
 
402
402
  def sum(sign, time = ::Time.current)
403
- parts.inject(time) do |t, (type, number)|
404
- if t.acts_like?(:time) || t.acts_like?(:date)
403
+ unless time.acts_like?(:time) || time.acts_like?(:date)
404
+ raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
405
+ end
406
+
407
+ if parts.empty?
408
+ time.since(sign * value)
409
+ else
410
+ parts.inject(time) do |t, (type, number)|
405
411
  if type == :seconds
406
412
  t.since(sign * number)
407
413
  elsif type == :minutes
@@ -411,8 +417,6 @@ module ActiveSupport
411
417
  else
412
418
  t.advance(type => sign * number)
413
419
  end
414
- else
415
- raise ::ArgumentError, "expected a time or date, got #{time.inspect}"
416
420
  end
417
421
  end
418
422
  end
@@ -9,8 +9,8 @@ module ActiveSupport
9
9
  module VERSION
10
10
  MAJOR = 5
11
11
  MINOR = 2
12
- TINY = 2
13
- PRE = "1"
12
+ TINY = 5
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -163,6 +163,19 @@ module ActiveSupport
163
163
  super(convert_key(key))
164
164
  end
165
165
 
166
+ # Same as <tt>Hash#assoc</tt> where the key passed as argument can be
167
+ # either a string or a symbol:
168
+ #
169
+ # counters = ActiveSupport::HashWithIndifferentAccess.new
170
+ # counters[:foo] = 1
171
+ #
172
+ # counters.assoc('foo') # => ["foo", 1]
173
+ # counters.assoc(:foo) # => ["foo", 1]
174
+ # counters.assoc(:zoo) # => nil
175
+ def assoc(key)
176
+ super(convert_key(key))
177
+ end
178
+
166
179
  # Same as <tt>Hash#fetch</tt> where the key passed as argument can be
167
180
  # either a string or a symbol:
168
181
  #
@@ -329,6 +329,8 @@ module ActiveSupport
329
329
  e.name.to_s == camel_cased_word.to_s)
330
330
  rescue ArgumentError => e
331
331
  raise unless /not missing constant #{const_regexp(camel_cased_word)}!$/.match?(e.message)
332
+ rescue LoadError => e
333
+ raise unless /Unable to autoload constant #{const_regexp(camel_cased_word)}/.match?(e.message)
332
334
  end
333
335
 
334
336
  # Returns the suffix that should be added to a number to denote the position
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/concern"
4
+ require "fiber"
4
5
 
5
6
  module ActiveSupport
6
7
  module LoggerThreadSafeLevel # :nodoc:
@@ -11,7 +12,7 @@ module ActiveSupport
11
12
  end
12
13
 
13
14
  def local_log_id
14
- Thread.current.__id__
15
+ Fiber.current.__id__
15
16
  end
16
17
 
17
18
  def local_level
@@ -18,8 +18,8 @@ module ActiveSupport
18
18
  super
19
19
  end
20
20
 
21
- def subscribe(pattern = nil, block = Proc.new)
22
- subscriber = Subscribers.new pattern, block
21
+ def subscribe(pattern = nil, callable = nil, &block)
22
+ subscriber = Subscribers.new(pattern, callable || block)
23
23
  synchronize do
24
24
  @subscribers << subscriber
25
25
  @listeners_for.clear
@@ -39,7 +39,7 @@ module ActiveSupport
39
39
  end
40
40
 
41
41
  def method_missing(name, *args)
42
- name_string = name.to_s
42
+ name_string = name.to_s.dup
43
43
  if name_string.chomp!("=")
44
44
  self[name_string] = args.first
45
45
  else
@@ -75,7 +75,7 @@ module ActiveSupport
75
75
  begin
76
76
  BigDecimal(number)
77
77
  rescue ArgumentError
78
- BigDecimal("0")
78
+ BigDecimal(number.to_f.to_s)
79
79
  end
80
80
  else
81
81
  BigDecimal(number)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.2.1
4
+ version: 5.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-13 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -139,6 +139,7 @@ files:
139
139
  - lib/active_support/core_ext/date_time/calculations.rb
140
140
  - lib/active_support/core_ext/date_time/compatibility.rb
141
141
  - lib/active_support/core_ext/date_time/conversions.rb
142
+ - lib/active_support/core_ext/digest.rb
142
143
  - lib/active_support/core_ext/digest/uuid.rb
143
144
  - lib/active_support/core_ext/enumerable.rb
144
145
  - lib/active_support/core_ext/file.rb
@@ -197,6 +198,7 @@ files:
197
198
  - lib/active_support/core_ext/object/try.rb
198
199
  - lib/active_support/core_ext/object/with_options.rb
199
200
  - lib/active_support/core_ext/range.rb
201
+ - lib/active_support/core_ext/range/compare_range.rb
200
202
  - lib/active_support/core_ext/range/conversions.rb
201
203
  - lib/active_support/core_ext/range/each.rb
202
204
  - lib/active_support/core_ext/range/include_range.rb
@@ -331,8 +333,8 @@ homepage: http://rubyonrails.org
331
333
  licenses:
332
334
  - MIT
333
335
  metadata:
334
- source_code_uri: https://github.com/rails/rails/tree/v5.2.2.1/activesupport
335
- changelog_uri: https://github.com/rails/rails/blob/v5.2.2.1/activesupport/CHANGELOG.md
336
+ source_code_uri: https://github.com/rails/rails/tree/v5.2.5/activesupport
337
+ changelog_uri: https://github.com/rails/rails/blob/v5.2.5/activesupport/CHANGELOG.md
336
338
  post_install_message:
337
339
  rdoc_options:
338
340
  - "--encoding"
@@ -350,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
350
352
  - !ruby/object:Gem::Version
351
353
  version: '0'
352
354
  requirements: []
353
- rubygems_version: 3.0.1
355
+ rubygems_version: 3.1.2
354
356
  signing_key:
355
357
  specification_version: 4
356
358
  summary: A toolkit of support libraries and Ruby core extensions extracted from the