hanami-action 3.0.2 → 3.0.3
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 +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/hanami/action/params.rb +32 -14
- data/lib/hanami/action/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 50013e29010b3035dd73368ab42ca9e1348478cb876200dd7379ecca324041f2
|
|
4
|
+
data.tar.gz: 34f4e51c7349d35d3c5888766f14e1ebb09ac48091c34803b47aac7be22aac08
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 78cd680b7f07b09cb4b2bc350202c2335e53402c5b6dd48bac04c6e80c220ced8a8f7d6e5d605029d72d4cd5e0383a39d4a0850c97eb80b949dd70ecf3804750
|
|
7
|
+
data.tar.gz: eedf3f7cbab7b5be7b11d52f602b383197de698f9396220c85093305e03869e0dee007f6e1089fd8255372b3aceb7a5cdb648b8eb94d8eb7a20d829b09bff134
|
data/CHANGELOG.md
CHANGED
|
@@ -19,7 +19,19 @@ and this project adheres to [Break Versioning](https://www.taoensso.com/break-ve
|
|
|
19
19
|
|
|
20
20
|
### Security
|
|
21
21
|
|
|
22
|
-
[Unreleased]: https://github.com/hanami/hanami-action/compare/v3.0.
|
|
22
|
+
[Unreleased]: https://github.com/hanami/hanami-action/compare/v3.0.3...HEAD
|
|
23
|
+
|
|
24
|
+
## [3.0.3] - 2026-11-25
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- Accept the CSRF token from a form body in routed requests again. Since 3.0.2, the String keys of query string and form body params were dropped from `params.raw` when Hanami Router also gave them as route params, so CSRF protection could not find `_csrf_token` and rejected every form submission. Both keys are now kept, with the same value. (@parndt in #537)
|
|
29
|
+
|
|
30
|
+
### Security
|
|
31
|
+
|
|
32
|
+
- Give route params precedence over request body params with the same name, such as a JSON or multipart body sending `id=2` to `/users/1`. This completes the fix for GHSA-55j2-5pph-56mv, which covered only the query string and form body. As a result, when the same flat param is in both the query string and the body, the query string value is now used; previously the body value was. Nested params in the body still take precedence over the query string. (@parndt in GHSA-55j2-5pph-56mv)
|
|
33
|
+
|
|
34
|
+
[3.0.2]: https://github.com/hanami/hanami-action/compare/v3.0.2...v3.0.3
|
|
23
35
|
|
|
24
36
|
## [3.0.2] - 2026-11-24
|
|
25
37
|
|
data/lib/hanami/action/params.rb
CHANGED
|
@@ -324,29 +324,47 @@ module Hanami
|
|
|
324
324
|
result = {}
|
|
325
325
|
rack_request = ::Rack::Request.new(env) if has_query || has_form_body
|
|
326
326
|
|
|
327
|
-
|
|
328
|
-
|
|
327
|
+
result.merge!(rack_request.GET) if has_query
|
|
328
|
+
result.merge!(rack_request.POST) if has_form_body
|
|
329
329
|
_merge_params(result, env[ROUTER_PARAMS]) if has_router_params
|
|
330
|
-
|
|
330
|
+
|
|
331
|
+
if has_body_params
|
|
332
|
+
_merge_params(result, env[ACTION_BODY_PARAMS])
|
|
333
|
+
_merge_router_string_params(result, env[ROUTER_PARAMS]) if has_router_params
|
|
334
|
+
end
|
|
331
335
|
|
|
332
336
|
result
|
|
333
337
|
end
|
|
334
338
|
|
|
335
|
-
#
|
|
336
|
-
#
|
|
337
|
-
#
|
|
338
|
-
#
|
|
339
|
+
# Query string, form body, and body params have String keys, while route params have Symbol
|
|
340
|
+
# keys. Hanami Router also copies query and form params into the route params, so the same
|
|
341
|
+
# param is often present under both keys. Both must hold the value merged last, or a route
|
|
342
|
+
# param would not override a query or form param of the same name wherever it is read.
|
|
339
343
|
def _merge_params(result, params)
|
|
340
|
-
params.each
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
344
|
+
params.each { |key, value| _merge_param(result, key, value) }
|
|
345
|
+
end
|
|
346
|
+
|
|
347
|
+
# Hanami Router gives no way to tell path params apart from the query and form params it
|
|
348
|
+
# copies alongside them, so a body merged after the route params could override a path param.
|
|
349
|
+
# Path params are always Strings (or nil for an optional segment that did not match, which
|
|
350
|
+
# leaves no value to protect), so merging the String values again puts them back on top.
|
|
351
|
+
def _merge_router_string_params(result, router_params)
|
|
352
|
+
router_params.each do |key, value|
|
|
353
|
+
_merge_param(result, key, value) if value.is_a?(String)
|
|
347
354
|
end
|
|
348
355
|
end
|
|
349
356
|
|
|
357
|
+
def _merge_param(result, key, value)
|
|
358
|
+
case key
|
|
359
|
+
when Symbol
|
|
360
|
+
result[key.name] = value if result.key?(key.name)
|
|
361
|
+
when String
|
|
362
|
+
result[key.to_sym] = value if key.valid_encoding? && result.key?(key.to_sym)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
result[key] = value
|
|
366
|
+
end
|
|
367
|
+
|
|
350
368
|
def _form_content_type?(content_type)
|
|
351
369
|
return false unless content_type
|
|
352
370
|
|