hanami-controller 2.3.2 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6890f3ebef71d678a0aa93a2d3d18ede49bcf470604119fc2181e4f8b79733ff
4
- data.tar.gz: 1eec0d50f763fda0bbc28016204d140e5c2ec8c2fb28dbf7d7beb32fecb6114a
3
+ metadata.gz: cdf1ca70c2649462e33ae672f3c583ad5e7e80a4ce375f637c8ed247b19a408a
4
+ data.tar.gz: 2c0384bcbe161e1e856340c6f2e0312ebfbbfe70536a278282d1171c617c269a
5
5
  SHA512:
6
- metadata.gz: 7b0f1f4302baef1ffc00af8458e15bd152f756289586b8e8c324f3c302387151626514a19f803924bdd28df040922066184a4fe9525044dc807a01d86392f8f0
7
- data.tar.gz: dc60b583a39ed2cfc4f1fbbee7839b91c58743c13f34f0550609f8cc6182f6d192a43d863630a09f51db7210e5aaf2e24224a868ad51510a744c7632b6b86cd8
6
+ metadata.gz: 7c31331561d5cb2037080b6adca0bbecda796dea8c683062724771344a9ca2279c9e7ef3b7bb416c67f5c427cfe3bae1ee84e9e0befebe3ef1fc718c94f0a8d4
7
+ data.tar.gz: f10923e5cbb74be9f22c05c36fa16d34cdd46902fb812af66e279a351c25bee3d3ffbd3160c5047ed79ba7a6de6749fb27b3418380478f5e5e978aada33f0637
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-controller/compare/v2.3.2...HEAD
22
+ [Unreleased]: https://github.com/hanami/hanami-controller/compare/v2.3.3...HEAD
23
+
24
+ ## [2.3.3] - 2026-12-02
25
+
26
+ ### Fixed
27
+
28
+ - Accept the CSRF token from a form body in routed requests. With the fix for GHSA-55j2-5pph-56mv alone, 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 query string and form body params with the same name in actions with a contract. Route params have Symbol keys and the others have String keys, so both were kept and the contract read the query or form value, letting `?id=2` override the `:id` in `/users/1`. (@parndt in GHSA-55j2-5pph-56mv)
33
+
34
+ [2.3.3]: https://github.com/hanami/hanami-controller/compare/v2.3.2...v2.3.3
23
35
 
24
36
  ## [2.3.2] - 2026-06-12
25
37
 
@@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.extra_rdoc_files = ["README.md", "CHANGELOG.md", "LICENSE"]
25
25
 
26
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
27
26
  spec.metadata["changelog_uri"] = "https://github.com/hanami/hanami-controller/blob/main/CHANGELOG.md"
28
27
  spec.metadata["source_code_uri"] = "https://github.com/hanami/hanami-controller"
29
28
  spec.metadata["bug_tracker_uri"] = "https://github.com/hanami/hanami-controller/issues"
@@ -37,4 +36,3 @@ Gem::Specification.new do |spec|
37
36
  spec.add_runtime_dependency "dry-core", "~> 1.0"
38
37
  spec.add_runtime_dependency "zeitwerk", "~> 2.6"
39
38
  end
40
-
@@ -343,6 +343,16 @@ module Hanami
343
343
 
344
344
  private
345
345
 
346
+ # Returns the raw params: the query string and form body params from Rack, with Hanami Router's
347
+ # params merged over them.
348
+ #
349
+ # Route params take precedence over query string and body params because of two merges, both
350
+ # with the route params last:
351
+ #
352
+ # 1. Hanami Router builds its params from the body, query string and path params, merging the
353
+ # path params last. This ordering is specified in hanami-router's own specs.
354
+ # 2. This method merges the router's params over the Rack params.
355
+ #
346
356
  # @since 0.7.0
347
357
  # @api private
348
358
  def _extract_params
@@ -350,7 +360,7 @@ module Hanami
350
360
 
351
361
  if env.key?(Action::RACK_INPUT)
352
362
  result.merge! ::Rack::Request.new(env).params
353
- result.merge! _router_params
363
+ _merge_params(result, _router_params)
354
364
  else
355
365
  result.merge! _router_params(env)
356
366
  env[Action::REQUEST_METHOD] ||= Action::DEFAULT_REQUEST_METHOD
@@ -364,6 +374,35 @@ module Hanami
364
374
  def _router_params(fallback = {})
365
375
  env.fetch(ROUTER_PARAMS, fallback)
366
376
  end
377
+
378
+ # Merges params into result, writing each value under both the String and Symbol forms of
379
+ # its key.
380
+ #
381
+ # Rack params have String keys and router params have Symbol keys. A plain merge would keep
382
+ # both forms of a param, and reading the String form would return the Rack value rather than
383
+ # the router's.
384
+ #
385
+ # Existing keys have their values replaced, never removed, so code reading the String form
386
+ # (such as CSRF protection reading "_csrf_token") still finds them.
387
+ #
388
+ # @api private
389
+ def _merge_params(result, params)
390
+ params.each { |key, value| _merge_param(result, key, value) }
391
+ end
392
+
393
+ # @api private
394
+ def _merge_param(result, key, value)
395
+ case key
396
+ when Symbol
397
+ result[key.name] = value if result.key?(key.name)
398
+ when String
399
+ # A key that isn't valid UTF-8 can't match a route param, and converting it to a Symbol
400
+ # would raise.
401
+ result[key.to_sym] = value if key.valid_encoding? && result.key?(key.to_sym)
402
+ end
403
+
404
+ result[key] = value
405
+ end
367
406
  end
368
407
  end
369
408
  end
@@ -8,6 +8,6 @@ module Hanami
8
8
  #
9
9
  # @since 0.1.0
10
10
  # @api public
11
- VERSION = "2.3.2"
11
+ VERSION = "2.3.3"
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanami-controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hanakai team
@@ -133,7 +133,6 @@ homepage: https://hanamirb.org
133
133
  licenses:
134
134
  - MIT
135
135
  metadata:
136
- allowed_push_host: https://rubygems.org
137
136
  changelog_uri: https://github.com/hanami/hanami-controller/blob/main/CHANGELOG.md
138
137
  source_code_uri: https://github.com/hanami/hanami-controller
139
138
  bug_tracker_uri: https://github.com/hanami/hanami-controller/issues