activesupport 6.0.2.2 → 6.0.3.3

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.

Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +43 -0
  3. data/README.rdoc +1 -1
  4. data/lib/active_support/backtrace_cleaner.rb +0 -1
  5. data/lib/active_support/cache.rb +29 -28
  6. data/lib/active_support/cache/file_store.rb +7 -8
  7. data/lib/active_support/cache/mem_cache_store.rb +9 -19
  8. data/lib/active_support/cache/memory_store.rb +6 -7
  9. data/lib/active_support/cache/null_store.rb +3 -3
  10. data/lib/active_support/cache/redis_cache_store.rb +22 -17
  11. data/lib/active_support/cache/strategy/local_cache.rb +23 -23
  12. data/lib/active_support/callbacks.rb +0 -3
  13. data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +18 -0
  14. data/lib/active_support/concurrency/share_lock.rb +0 -1
  15. data/lib/active_support/core_ext/array/conversions.rb +5 -5
  16. data/lib/active_support/core_ext/date_and_time/zones.rb +0 -1
  17. data/lib/active_support/core_ext/date_time/conversions.rb +0 -1
  18. data/lib/active_support/core_ext/hash/conversions.rb +1 -1
  19. data/lib/active_support/core_ext/module/delegation.rb +8 -1
  20. data/lib/active_support/core_ext/module/introspection.rb +1 -0
  21. data/lib/active_support/core_ext/object/try.rb +2 -0
  22. data/lib/active_support/core_ext/range/each.rb +0 -1
  23. data/lib/active_support/core_ext/string/output_safety.rb +0 -1
  24. data/lib/active_support/dependencies.rb +0 -2
  25. data/lib/active_support/dependencies/zeitwerk_integration.rb +0 -1
  26. data/lib/active_support/deprecation/method_wrappers.rb +12 -6
  27. data/lib/active_support/deprecation/proxy_wrappers.rb +5 -1
  28. data/lib/active_support/descendants_tracker.rb +0 -1
  29. data/lib/active_support/duration.rb +13 -11
  30. data/lib/active_support/duration/iso8601_parser.rb +0 -1
  31. data/lib/active_support/duration/iso8601_serializer.rb +0 -1
  32. data/lib/active_support/encrypted_file.rb +1 -1
  33. data/lib/active_support/evented_file_update_checker.rb +0 -1
  34. data/lib/active_support/file_update_checker.rb +0 -1
  35. data/lib/active_support/gem_version.rb +2 -2
  36. data/lib/active_support/inflector/inflections.rb +0 -1
  37. data/lib/active_support/inflector/methods.rb +1 -2
  38. data/lib/active_support/json/decoding.rb +0 -1
  39. data/lib/active_support/lazy_load_hooks.rb +0 -1
  40. data/lib/active_support/locale/en.rb +4 -2
  41. data/lib/active_support/log_subscriber.rb +0 -1
  42. data/lib/active_support/logger.rb +1 -1
  43. data/lib/active_support/message_encryptor.rb +1 -1
  44. data/lib/active_support/message_verifier.rb +2 -2
  45. data/lib/active_support/messages/metadata.rb +3 -2
  46. data/lib/active_support/messages/rotator.rb +4 -4
  47. data/lib/active_support/multibyte/chars.rb +1 -2
  48. data/lib/active_support/multibyte/unicode.rb +0 -1
  49. data/lib/active_support/notifications/instrumenter.rb +0 -1
  50. data/lib/active_support/number_helper.rb +4 -0
  51. data/lib/active_support/number_helper/number_converter.rb +4 -5
  52. data/lib/active_support/number_helper/number_to_currency_converter.rb +7 -8
  53. data/lib/active_support/number_helper/number_to_delimited_converter.rb +0 -1
  54. data/lib/active_support/number_helper/number_to_human_converter.rb +0 -1
  55. data/lib/active_support/number_helper/number_to_human_size_converter.rb +0 -1
  56. data/lib/active_support/number_helper/number_to_phone_converter.rb +0 -1
  57. data/lib/active_support/number_helper/number_to_rounded_converter.rb +0 -1
  58. data/lib/active_support/option_merger.rb +21 -3
  59. data/lib/active_support/ordered_options.rb +4 -0
  60. data/lib/active_support/parameter_filter.rb +1 -2
  61. data/lib/active_support/string_inquirer.rb +0 -1
  62. data/lib/active_support/testing/parallelization.rb +8 -2
  63. data/lib/active_support/testing/stream.rb +0 -1
  64. data/lib/active_support/testing/time_helpers.rb +0 -2
  65. data/lib/active_support/xml_mini.rb +0 -1
  66. data/lib/active_support/xml_mini/jdom.rb +0 -1
  67. metadata +13 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7bf8048c7cb74c8a78b675b8a60c273101aeeae4160b72754fa4f25cf99d32f0
4
- data.tar.gz: d7863b004d5dc872914d96a429f7a4046d3adcf738b9a6d6ac18080819fc1f7a
3
+ metadata.gz: f1e4aacc5a6ee4b2a94a03448b8f9156885db3a419849011bab59e8d329b116a
4
+ data.tar.gz: ee620813b9d428827e3b42e039e8c3c1a9d9af1b8034edbe3b22bd6e009de2f6
5
5
  SHA512:
6
- metadata.gz: 70a16e7d86c63ddd518f5013d00b2e4730a3a1d9847f8e31d151c40e250934f216eeb4c4277921d869fff015479dc1aeca05c8b87e782c75dcebbed1ff8cd776
7
- data.tar.gz: 549b1f814d15ec89d3468425f976a6c38a5e50a3827088d3aef600fdfd1666fe84ca8ab2afc277d491e3dcd1a712c489bd8dc3eca4e1ad40a272471c7df58998
6
+ metadata.gz: d1c4eae0e5b306823481d8d58f85b05d0ed1fcfe7af7273184244363dc80b7db8b5d44b6addeae0566e457296e13df5caeca97139b8dc9226658a216af91c259
7
+ data.tar.gz: c01d989cba1a5cd88d2499be9e70c25a09beac2145999904fee502b343a11068b1752db1e1350754502037f5b8d0efa58de5b471de66bc90025820fc408a4dbd
@@ -1,3 +1,46 @@
1
+ ## Rails 6.0.3.3 (September 09, 2020) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 6.0.3.2 (June 17, 2020) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 6.0.3.1 (May 18, 2020) ##
12
+
13
+ * [CVE-2020-8165] Deprecate Marshal.load on raw cache read in RedisCacheStore
14
+
15
+ * [CVE-2020-8165] Avoid Marshal.load on raw cache value in MemCacheStore
16
+
17
+ ## Rails 6.0.3 (May 06, 2020) ##
18
+
19
+ * `Array#to_sentence` no longer returns a frozen string.
20
+
21
+ Before:
22
+
23
+ ['one', 'two'].to_sentence.frozen?
24
+ # => true
25
+
26
+ After:
27
+
28
+ ['one', 'two'].to_sentence.frozen?
29
+ # => false
30
+
31
+ *Nicolas Dular*
32
+
33
+ * Update `ActiveSupport::Messages::Metadata#fresh?` to work for cookies with expiry set when
34
+ `ActiveSupport.parse_json_times = true`.
35
+
36
+ *Christian Gregg*
37
+
38
+
39
+ ## Rails 6.0.2.2 (March 19, 2020) ##
40
+
41
+ * No changes.
42
+
43
+
1
44
  ## Rails 6.0.2.1 (December 18, 2019) ##
2
45
 
3
46
  * No changes.
@@ -37,4 +37,4 @@ Bug reports for the Ruby on Rails project can be filed here:
37
37
 
38
38
  Feature requests should be discussed on the rails-core mailing list here:
39
39
 
40
- * https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core
40
+ * https://discuss.rubyonrails.org/c/rubyonrails-core
@@ -85,7 +85,6 @@ module ActiveSupport
85
85
  end
86
86
 
87
87
  private
88
-
89
88
  FORMATTED_GEMS_PATTERN = /\A[^\/]+ \([\w.]+\) /
90
89
 
91
90
  def add_gem_filter
@@ -52,12 +52,13 @@ module ActiveSupport
52
52
  #
53
53
  # ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
54
54
  # # => returns MyOwnCacheStore.new
55
- def lookup_store(*store_option)
56
- store, *parameters = *Array.wrap(store_option).flatten
57
-
55
+ def lookup_store(store = nil, *parameters)
58
56
  case store
59
57
  when Symbol
60
- retrieve_store_class(store).new(*parameters)
58
+ options = parameters.extract_options!
59
+ retrieve_store_class(store).new(*parameters, **options)
60
+ when Array
61
+ lookup_store(*store)
61
62
  when nil
62
63
  ActiveSupport::Cache::MemoryStore.new
63
64
  else
@@ -318,7 +319,7 @@ module ActiveSupport
318
319
 
319
320
  entry = nil
320
321
  instrument(:read, name, options) do |payload|
321
- cached_entry = read_entry(key, options) unless options[:force]
322
+ cached_entry = read_entry(key, **options) unless options[:force]
322
323
  entry = handle_expired_entry(cached_entry, key, options)
323
324
  entry = nil if entry && entry.mismatched?(normalize_version(name, options))
324
325
  payload[:super_operation] = :fetch if payload
@@ -326,9 +327,9 @@ module ActiveSupport
326
327
  end
327
328
 
328
329
  if entry
329
- get_entry_value(entry, name, options)
330
+ get_entry_value(entry, name, **options)
330
331
  else
331
- save_block_result_to_cache(name, options) { |_name| yield _name }
332
+ save_block_result_to_cache(name, **options) { |_name| yield _name }
332
333
  end
333
334
  elsif options && options[:force]
334
335
  raise ArgumentError, "Missing block: Calling `Cache#fetch` with `force: true` requires a block."
@@ -352,11 +353,11 @@ module ActiveSupport
352
353
  version = normalize_version(name, options)
353
354
 
354
355
  instrument(:read, name, options) do |payload|
355
- entry = read_entry(key, options)
356
+ entry = read_entry(key, **options)
356
357
 
357
358
  if entry
358
359
  if entry.expired?
359
- delete_entry(key, options)
360
+ delete_entry(key, **options)
360
361
  payload[:hit] = false if payload
361
362
  nil
362
363
  elsif entry.mismatched?(version)
@@ -384,7 +385,7 @@ module ActiveSupport
384
385
  options = merged_options(options)
385
386
 
386
387
  instrument :read_multi, names, options do |payload|
387
- read_multi_entries(names, options).tap do |results|
388
+ read_multi_entries(names, **options).tap do |results|
388
389
  payload[:hits] = results.keys
389
390
  end
390
391
  end
@@ -396,10 +397,10 @@ module ActiveSupport
396
397
 
397
398
  instrument :write_multi, hash, options do |payload|
398
399
  entries = hash.each_with_object({}) do |(name, value), memo|
399
- memo[normalize_key(name, options)] = Entry.new(value, options.merge(version: normalize_version(name, options)))
400
+ memo[normalize_key(name, options)] = Entry.new(value, **options.merge(version: normalize_version(name, options)))
400
401
  end
401
402
 
402
- write_multi_entries entries, options
403
+ write_multi_entries entries, **options
403
404
  end
404
405
  end
405
406
 
@@ -438,7 +439,7 @@ module ActiveSupport
438
439
  options = merged_options(options)
439
440
 
440
441
  instrument :read_multi, names, options do |payload|
441
- reads = read_multi_entries(names, options)
442
+ reads = read_multi_entries(names, **options)
442
443
  writes = {}
443
444
  ordered = names.each_with_object({}) do |name, hash|
444
445
  hash[name] = reads.fetch(name) { writes[name] = yield(name) }
@@ -447,7 +448,7 @@ module ActiveSupport
447
448
  payload[:hits] = reads.keys
448
449
  payload[:super_operation] = :fetch_multi
449
450
 
450
- write_multi(writes, options)
451
+ write_multi(writes, **options)
451
452
 
452
453
  ordered
453
454
  end
@@ -460,8 +461,8 @@ module ActiveSupport
460
461
  options = merged_options(options)
461
462
 
462
463
  instrument(:write, name, options) do
463
- entry = Entry.new(value, options.merge(version: normalize_version(name, options)))
464
- write_entry(normalize_key(name, options), entry, options)
464
+ entry = Entry.new(value, **options.merge(version: normalize_version(name, options)))
465
+ write_entry(normalize_key(name, options), entry, **options)
465
466
  end
466
467
  end
467
468
 
@@ -472,7 +473,7 @@ module ActiveSupport
472
473
  options = merged_options(options)
473
474
 
474
475
  instrument(:delete, name) do
475
- delete_entry(normalize_key(name, options), options)
476
+ delete_entry(normalize_key(name, options), **options)
476
477
  end
477
478
  end
478
479
 
@@ -483,7 +484,7 @@ module ActiveSupport
483
484
  options = merged_options(options)
484
485
 
485
486
  instrument(:exist?, name) do
486
- entry = read_entry(normalize_key(name, options), options)
487
+ entry = read_entry(normalize_key(name, options), **options)
487
488
  (entry && !entry.expired? && !entry.mismatched?(normalize_version(name, options))) || false
488
489
  end
489
490
  end
@@ -556,28 +557,28 @@ module ActiveSupport
556
557
 
557
558
  # Reads an entry from the cache implementation. Subclasses must implement
558
559
  # this method.
559
- def read_entry(key, options)
560
+ def read_entry(key, **options)
560
561
  raise NotImplementedError.new
561
562
  end
562
563
 
563
564
  # Writes an entry to the cache implementation. Subclasses must implement
564
565
  # this method.
565
- def write_entry(key, entry, options)
566
+ def write_entry(key, entry, **options)
566
567
  raise NotImplementedError.new
567
568
  end
568
569
 
569
570
  # Reads multiple entries from the cache implementation. Subclasses MAY
570
571
  # implement this method.
571
- def read_multi_entries(names, options)
572
+ def read_multi_entries(names, **options)
572
573
  results = {}
573
574
  names.each do |name|
574
575
  key = normalize_key(name, options)
575
576
  version = normalize_version(name, options)
576
- entry = read_entry(key, options)
577
+ entry = read_entry(key, **options)
577
578
 
578
579
  if entry
579
580
  if entry.expired?
580
- delete_entry(key, options)
581
+ delete_entry(key, **options)
581
582
  elsif entry.mismatched?(version)
582
583
  # Skip mismatched versions
583
584
  else
@@ -590,15 +591,15 @@ module ActiveSupport
590
591
 
591
592
  # Writes multiple entries to the cache implementation. Subclasses MAY
592
593
  # implement this method.
593
- def write_multi_entries(hash, options)
594
+ def write_multi_entries(hash, **options)
594
595
  hash.each do |key, entry|
595
- write_entry key, entry, options
596
+ write_entry key, entry, **options
596
597
  end
597
598
  end
598
599
 
599
600
  # Deletes an entry from the cache implementation. Subclasses must
600
601
  # implement this method.
601
- def delete_entry(key, options)
602
+ def delete_entry(key, **options)
602
603
  raise NotImplementedError.new
603
604
  end
604
605
 
@@ -699,7 +700,7 @@ module ActiveSupport
699
700
  entry.expires_at = Time.now + race_ttl
700
701
  write_entry(key, entry, expires_in: race_ttl * 2)
701
702
  else
702
- delete_entry(key, options)
703
+ delete_entry(key, **options)
703
704
  end
704
705
  entry = nil
705
706
  end
@@ -711,7 +712,7 @@ module ActiveSupport
711
712
  entry.value
712
713
  end
713
714
 
714
- def save_block_result_to_cache(name, options)
715
+ def save_block_result_to_cache(name, **options)
715
716
  result = instrument(:generate, name, options) do
716
717
  yield(name)
717
718
  end
@@ -36,15 +36,15 @@ module ActiveSupport
36
36
  def clear(options = nil)
37
37
  root_dirs = (Dir.children(cache_path) - GITKEEP_FILES)
38
38
  FileUtils.rm_r(root_dirs.collect { |f| File.join(cache_path, f) })
39
- rescue Errno::ENOENT
39
+ rescue Errno::ENOENT, Errno::ENOTEMPTY
40
40
  end
41
41
 
42
42
  # Preemptively iterates through all stored keys and removes the ones which have expired.
43
43
  def cleanup(options = nil)
44
44
  options = merged_options(options)
45
45
  search_dir(cache_path) do |fname|
46
- entry = read_entry(fname, options)
47
- delete_entry(fname, options) if entry && entry.expired?
46
+ entry = read_entry(fname, **options)
47
+ delete_entry(fname, **options) if entry && entry.expired?
48
48
  end
49
49
  end
50
50
 
@@ -66,14 +66,13 @@ module ActiveSupport
66
66
  matcher = key_matcher(matcher, options)
67
67
  search_dir(cache_path) do |path|
68
68
  key = file_path_key(path)
69
- delete_entry(path, options) if key.match(matcher)
69
+ delete_entry(path, **options) if key.match(matcher)
70
70
  end
71
71
  end
72
72
  end
73
73
 
74
74
  private
75
-
76
- def read_entry(key, options)
75
+ def read_entry(key, **options)
77
76
  if File.exist?(key)
78
77
  File.open(key) { |f| Marshal.load(f) }
79
78
  end
@@ -82,14 +81,14 @@ module ActiveSupport
82
81
  nil
83
82
  end
84
83
 
85
- def write_entry(key, entry, options)
84
+ def write_entry(key, entry, **options)
86
85
  return false if options[:unless_exist] && File.exist?(key)
87
86
  ensure_cache_path(File.dirname(key))
88
87
  File.atomic_write(key, cache_path) { |f| Marshal.dump(entry, f) }
89
88
  true
90
89
  end
91
90
 
92
- def delete_entry(key, options)
91
+ def delete_entry(key, **options)
93
92
  if File.exist?(key)
94
93
  begin
95
94
  File.delete(key)
@@ -7,7 +7,6 @@ rescue LoadError => e
7
7
  raise e
8
8
  end
9
9
 
10
- require "active_support/core_ext/marshal"
11
10
  require "active_support/core_ext/array/extract_options"
12
11
 
13
12
  module ActiveSupport
@@ -28,19 +27,11 @@ module ActiveSupport
28
27
  # Provide support for raw values in the local cache strategy.
29
28
  module LocalCacheWithRaw # :nodoc:
30
29
  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
- def write_entry(key, entry, options)
30
+ def write_entry(key, entry, **options)
40
31
  if options[:raw] && local_cache
41
32
  raw_entry = Entry.new(entry.value.to_s)
42
33
  raw_entry.expires_at = entry.expires_at
43
- super(key, raw_entry, options)
34
+ super(key, raw_entry, **options)
44
35
  else
45
36
  super
46
37
  end
@@ -142,12 +133,12 @@ module ActiveSupport
142
133
 
143
134
  private
144
135
  # Read an entry from the cache.
145
- def read_entry(key, options)
136
+ def read_entry(key, **options)
146
137
  rescue_error_with(nil) { deserialize_entry(@data.with { |c| c.get(key, options) }) }
147
138
  end
148
139
 
149
140
  # Write an entry to the cache.
150
- def write_entry(key, entry, options)
141
+ def write_entry(key, entry, **options)
151
142
  method = options && options[:unless_exist] ? :add : :set
152
143
  value = options[:raw] ? entry.value.to_s : entry
153
144
  expires_in = options[:expires_in].to_i
@@ -156,12 +147,12 @@ module ActiveSupport
156
147
  expires_in += 5.minutes
157
148
  end
158
149
  rescue_error_with false do
159
- @data.with { |c| c.send(method, key, value, expires_in, options) }
150
+ @data.with { |c| c.send(method, key, value, expires_in, **options) }
160
151
  end
161
152
  end
162
153
 
163
154
  # Reads multiple entries from the cache implementation.
164
- def read_multi_entries(names, options)
155
+ def read_multi_entries(names, **options)
165
156
  keys_to_names = Hash[names.map { |name| [normalize_key(name, options), name] }]
166
157
 
167
158
  raw_values = @data.with { |c| c.get_multi(keys_to_names.keys) }
@@ -179,7 +170,7 @@ module ActiveSupport
179
170
  end
180
171
 
181
172
  # Delete an entry from the cache.
182
- def delete_entry(key, options)
173
+ def delete_entry(key, **options)
183
174
  rescue_error_with(false) { @data.with { |c| c.delete(key) } }
184
175
  end
185
176
 
@@ -194,9 +185,8 @@ module ActiveSupport
194
185
  key
195
186
  end
196
187
 
197
- def deserialize_entry(raw_value)
198
- if raw_value
199
- entry = Marshal.load(raw_value) rescue raw_value
188
+ def deserialize_entry(entry)
189
+ if entry
200
190
  entry.is_a?(Entry) ? entry : Entry.new(entry)
201
191
  end
202
192
  end
@@ -51,7 +51,7 @@ module ActiveSupport
51
51
  keys = synchronize { @data.keys }
52
52
  keys.each do |key|
53
53
  entry = @data[key]
54
- delete_entry(key, options) if entry && entry.expired?
54
+ delete_entry(key, **options) if entry && entry.expired?
55
55
  end
56
56
  end
57
57
  end
@@ -67,7 +67,7 @@ module ActiveSupport
67
67
  instrument(:prune, target_size, from: @cache_size) do
68
68
  keys = synchronize { @key_access.keys.sort { |a, b| @key_access[a].to_f <=> @key_access[b].to_f } }
69
69
  keys.each do |key|
70
- delete_entry(key, options)
70
+ delete_entry(key, **options)
71
71
  return if @cache_size <= target_size || (max_time && Concurrent.monotonic_time - start_time > max_time)
72
72
  end
73
73
  end
@@ -98,7 +98,7 @@ module ActiveSupport
98
98
  matcher = key_matcher(matcher, options)
99
99
  keys = synchronize { @data.keys }
100
100
  keys.each do |key|
101
- delete_entry(key, options) if key.match(matcher)
101
+ delete_entry(key, **options) if key.match(matcher)
102
102
  end
103
103
  end
104
104
  end
@@ -114,14 +114,13 @@ module ActiveSupport
114
114
  end
115
115
 
116
116
  private
117
-
118
117
  PER_ENTRY_OVERHEAD = 240
119
118
 
120
119
  def cached_size(key, entry)
121
120
  key.to_s.bytesize + entry.size + PER_ENTRY_OVERHEAD
122
121
  end
123
122
 
124
- def read_entry(key, options)
123
+ def read_entry(key, **options)
125
124
  entry = @data[key]
126
125
  synchronize do
127
126
  if entry
@@ -135,7 +134,7 @@ module ActiveSupport
135
134
  entry
136
135
  end
137
136
 
138
- def write_entry(key, entry, options)
137
+ def write_entry(key, entry, **options)
139
138
  entry.dup_value!
140
139
  synchronize do
141
140
  old_entry = @data[key]
@@ -152,7 +151,7 @@ module ActiveSupport
152
151
  end
153
152
  end
154
153
 
155
- def delete_entry(key, options)
154
+ def delete_entry(key, **options)
156
155
  synchronize do
157
156
  @key_access.delete(key)
158
157
  entry = @data.delete(key)