ransack 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0251527dc22cca8cb55ff672b598d74fef0ec4c2b1c6336cb0b8d52d69dabafc
4
- data.tar.gz: fd218c05d4697cca5b9a8b4111af7a5fa4ddc559071e9a3194aca2f2b2da6c9d
3
+ metadata.gz: 488db32f12e0902a6194cc3f5d0b4e08676b8533302f00a2bd30739f0bead9de
4
+ data.tar.gz: f884ce36bbb02c25a58c2293f75d1147a790075242b11fec6a24b487a1d39f19
5
5
  SHA512:
6
- metadata.gz: bc524a7f9a4fac90d6f2e3b9818ccf76bab0f44c872c33db043f049f759f2641c03b338c2cfa28c70a20f6d1d2c4569390e43ec9e5da9daf2537002c519ad3fc
7
- data.tar.gz: 3a599c3c9472f0033976ed0301cc0545b62711cccb36817db373c0f19ba0b828640a89bc3784b533346633112fb017353c63c490fa792b3eb3e7aea82f41e527
6
+ metadata.gz: eb8990b59a5d2c06eda4851c80682628f3f818cfc9d6a8e6a68c870a7e69d36e97406bc4606e0234c8a1325e8bde143930e6849eb3afbf834a707c7fa89063a6
7
+ data.tar.gz: 97b4c79957abc27206b8a0de0a681a13904a0e80de942c8fd0501edc03d56c166bab15f456a6c5e1abecf2f0f2a142e854b2c01509db0a85da41b258b2b7a16d
@@ -147,19 +147,31 @@ module Ransack
147
147
  @context.chain_scope(key, sanitized_args)
148
148
  end
149
149
 
150
+ # The largest position a multiparameter key (`created_at(1i)`) may carry.
151
+ # Rails' date and time selects emit at most six, year to second. The
152
+ # position indexes an array, so an unbounded one from a crafted query
153
+ # string would allocate an array that size (GHSA-vxc9-rm8f-p56j).
154
+ MULTIPARAMETER_POSITION_LIMIT = 16
155
+
156
+ # Folds `created_at(1i)`, `created_at(2i)`, ... into `created_at` as an
157
+ # array of cast values, the way Active Record does for form input. The
158
+ # keys are untrusted, so a malformed one is dropped rather than raised
159
+ # on: no position (`created_at(`), a position outside 1 to the limit,
160
+ # or a fragment for an attribute that was also given as a plain value.
150
161
  def collapse_multiparameter_attributes!(attrs)
151
162
  attrs.keys.each do |k|
152
163
  if k.include?(Constants::LEFT_PARENTHESIS)
153
164
  real_attribute, position = k.split(/\(|\)/)
154
- cast =
155
- if Constants::A_S_I.include?(position.last)
156
- position.last
157
- else
158
- nil
159
- end
160
- position = position.to_i - 1
161
165
  value = attrs.delete(k)
166
+ next if position.nil?
167
+
168
+ cast = Constants::A_S_I.include?(position.last) ? position.last : nil
169
+ position = position.to_i - 1
170
+ next if position < 0 || position >= MULTIPARAMETER_POSITION_LIMIT
171
+
162
172
  attrs[real_attribute] ||= []
173
+ next unless attrs[real_attribute].is_a?(Array)
174
+
163
175
  attrs[real_attribute][position] =
164
176
  if cast
165
177
  if value.blank? && cast == Constants::I
@@ -1,3 +1,3 @@
1
1
  module Ransack
2
- VERSION = '5.0.0'
2
+ VERSION = '5.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ransack
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ernie Miller