actionpack 7.1.6 → 8.1.2

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.
Files changed (177) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +308 -533
  3. data/README.rdoc +1 -1
  4. data/lib/abstract_controller/asset_paths.rb +6 -2
  5. data/lib/abstract_controller/base.rb +104 -105
  6. data/lib/abstract_controller/caching/fragments.rb +50 -53
  7. data/lib/abstract_controller/caching.rb +8 -3
  8. data/lib/abstract_controller/callbacks.rb +70 -62
  9. data/lib/abstract_controller/collector.rb +7 -7
  10. data/lib/abstract_controller/deprecator.rb +2 -0
  11. data/lib/abstract_controller/error.rb +2 -0
  12. data/lib/abstract_controller/helpers.rb +71 -84
  13. data/lib/abstract_controller/logger.rb +4 -1
  14. data/lib/abstract_controller/railties/routes_helpers.rb +2 -0
  15. data/lib/abstract_controller/rendering.rb +13 -13
  16. data/lib/abstract_controller/translation.rb +12 -13
  17. data/lib/abstract_controller/url_for.rb +8 -6
  18. data/lib/abstract_controller.rb +2 -0
  19. data/lib/action_controller/api/api_rendering.rb +2 -0
  20. data/lib/action_controller/api.rb +76 -72
  21. data/lib/action_controller/base.rb +199 -126
  22. data/lib/action_controller/caching.rb +16 -14
  23. data/lib/action_controller/deprecator.rb +2 -0
  24. data/lib/action_controller/form_builder.rb +21 -18
  25. data/lib/action_controller/log_subscriber.rb +23 -2
  26. data/lib/action_controller/metal/allow_browser.rb +133 -0
  27. data/lib/action_controller/metal/basic_implicit_render.rb +2 -0
  28. data/lib/action_controller/metal/conditional_get.rb +217 -175
  29. data/lib/action_controller/metal/content_security_policy.rb +25 -24
  30. data/lib/action_controller/metal/cookies.rb +4 -2
  31. data/lib/action_controller/metal/data_streaming.rb +72 -65
  32. data/lib/action_controller/metal/default_headers.rb +5 -3
  33. data/lib/action_controller/metal/etag_with_flash.rb +3 -1
  34. data/lib/action_controller/metal/etag_with_template_digest.rb +17 -15
  35. data/lib/action_controller/metal/exceptions.rb +16 -9
  36. data/lib/action_controller/metal/flash.rb +13 -14
  37. data/lib/action_controller/metal/head.rb +15 -11
  38. data/lib/action_controller/metal/helpers.rb +63 -55
  39. data/lib/action_controller/metal/http_authentication.rb +209 -201
  40. data/lib/action_controller/metal/implicit_render.rb +17 -15
  41. data/lib/action_controller/metal/instrumentation.rb +16 -14
  42. data/lib/action_controller/metal/live.rb +175 -127
  43. data/lib/action_controller/metal/logging.rb +6 -4
  44. data/lib/action_controller/metal/mime_responds.rb +151 -142
  45. data/lib/action_controller/metal/parameter_encoding.rb +34 -32
  46. data/lib/action_controller/metal/params_wrapper.rb +57 -59
  47. data/lib/action_controller/metal/permissions_policy.rb +22 -12
  48. data/lib/action_controller/metal/rate_limiting.rb +92 -0
  49. data/lib/action_controller/metal/redirecting.rb +213 -94
  50. data/lib/action_controller/metal/renderers.rb +78 -57
  51. data/lib/action_controller/metal/rendering.rb +111 -77
  52. data/lib/action_controller/metal/request_forgery_protection.rb +182 -143
  53. data/lib/action_controller/metal/rescue.rb +20 -9
  54. data/lib/action_controller/metal/streaming.rb +118 -195
  55. data/lib/action_controller/metal/strong_parameters.rb +720 -530
  56. data/lib/action_controller/metal/testing.rb +2 -0
  57. data/lib/action_controller/metal/url_for.rb +17 -15
  58. data/lib/action_controller/metal.rb +86 -60
  59. data/lib/action_controller/railtie.rb +36 -15
  60. data/lib/action_controller/railties/helpers.rb +2 -0
  61. data/lib/action_controller/renderer.rb +41 -36
  62. data/lib/action_controller/structured_event_subscriber.rb +116 -0
  63. data/lib/action_controller/template_assertions.rb +4 -2
  64. data/lib/action_controller/test_case.rb +160 -131
  65. data/lib/action_controller.rb +5 -1
  66. data/lib/action_dispatch/constants.rb +8 -0
  67. data/lib/action_dispatch/deprecator.rb +2 -0
  68. data/lib/action_dispatch/http/cache.rb +163 -35
  69. data/lib/action_dispatch/http/content_disposition.rb +2 -0
  70. data/lib/action_dispatch/http/content_security_policy.rb +54 -39
  71. data/lib/action_dispatch/http/filter_parameters.rb +14 -8
  72. data/lib/action_dispatch/http/filter_redirect.rb +22 -1
  73. data/lib/action_dispatch/http/headers.rb +22 -22
  74. data/lib/action_dispatch/http/mime_negotiation.rb +89 -41
  75. data/lib/action_dispatch/http/mime_type.rb +25 -21
  76. data/lib/action_dispatch/http/mime_types.rb +3 -0
  77. data/lib/action_dispatch/http/param_builder.rb +187 -0
  78. data/lib/action_dispatch/http/param_error.rb +26 -0
  79. data/lib/action_dispatch/http/parameters.rb +14 -12
  80. data/lib/action_dispatch/http/permissions_policy.rb +25 -36
  81. data/lib/action_dispatch/http/query_parser.rb +55 -0
  82. data/lib/action_dispatch/http/rack_cache.rb +2 -0
  83. data/lib/action_dispatch/http/request.rb +141 -92
  84. data/lib/action_dispatch/http/response.rb +137 -77
  85. data/lib/action_dispatch/http/upload.rb +18 -16
  86. data/lib/action_dispatch/http/url.rb +187 -89
  87. data/lib/action_dispatch/journey/formatter.rb +21 -9
  88. data/lib/action_dispatch/journey/gtg/builder.rb +4 -3
  89. data/lib/action_dispatch/journey/gtg/simulator.rb +34 -11
  90. data/lib/action_dispatch/journey/gtg/transition_table.rb +47 -53
  91. data/lib/action_dispatch/journey/nfa/dot.rb +2 -0
  92. data/lib/action_dispatch/journey/nodes/node.rb +8 -6
  93. data/lib/action_dispatch/journey/parser.rb +99 -195
  94. data/lib/action_dispatch/journey/path/pattern.rb +4 -1
  95. data/lib/action_dispatch/journey/route.rb +54 -38
  96. data/lib/action_dispatch/journey/router/utils.rb +22 -27
  97. data/lib/action_dispatch/journey/router.rb +63 -83
  98. data/lib/action_dispatch/journey/routes.rb +11 -2
  99. data/lib/action_dispatch/journey/scanner.rb +46 -42
  100. data/lib/action_dispatch/journey/visitors.rb +57 -23
  101. data/lib/action_dispatch/journey/visualizer/fsm.js +4 -6
  102. data/lib/action_dispatch/journey.rb +2 -0
  103. data/lib/action_dispatch/log_subscriber.rb +7 -1
  104. data/lib/action_dispatch/middleware/actionable_exceptions.rb +2 -0
  105. data/lib/action_dispatch/middleware/assume_ssl.rb +8 -5
  106. data/lib/action_dispatch/middleware/callbacks.rb +3 -1
  107. data/lib/action_dispatch/middleware/cookies.rb +125 -106
  108. data/lib/action_dispatch/middleware/debug_exceptions.rb +37 -8
  109. data/lib/action_dispatch/middleware/debug_locks.rb +15 -13
  110. data/lib/action_dispatch/middleware/debug_view.rb +13 -5
  111. data/lib/action_dispatch/middleware/exception_wrapper.rb +18 -23
  112. data/lib/action_dispatch/middleware/executor.rb +19 -4
  113. data/lib/action_dispatch/middleware/flash.rb +63 -51
  114. data/lib/action_dispatch/middleware/host_authorization.rb +17 -15
  115. data/lib/action_dispatch/middleware/public_exceptions.rb +14 -12
  116. data/lib/action_dispatch/middleware/reloader.rb +5 -3
  117. data/lib/action_dispatch/middleware/remote_ip.rb +87 -77
  118. data/lib/action_dispatch/middleware/request_id.rb +16 -10
  119. data/lib/action_dispatch/middleware/server_timing.rb +4 -2
  120. data/lib/action_dispatch/middleware/session/abstract_store.rb +2 -0
  121. data/lib/action_dispatch/middleware/session/cache_store.rb +30 -8
  122. data/lib/action_dispatch/middleware/session/cookie_store.rb +27 -26
  123. data/lib/action_dispatch/middleware/session/mem_cache_store.rb +7 -3
  124. data/lib/action_dispatch/middleware/show_exceptions.rb +16 -16
  125. data/lib/action_dispatch/middleware/ssl.rb +53 -40
  126. data/lib/action_dispatch/middleware/stack.rb +11 -10
  127. data/lib/action_dispatch/middleware/static.rb +33 -31
  128. data/lib/action_dispatch/middleware/templates/rescues/_copy_button.html.erb +1 -0
  129. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +3 -5
  130. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +9 -5
  131. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +1 -0
  132. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +1 -0
  133. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +4 -0
  134. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +3 -0
  135. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +50 -0
  136. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +1 -0
  137. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +1 -0
  138. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +1 -0
  139. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -0
  140. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -0
  141. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +1 -1
  142. data/lib/action_dispatch/railtie.rb +23 -3
  143. data/lib/action_dispatch/request/session.rb +24 -21
  144. data/lib/action_dispatch/request/utils.rb +11 -3
  145. data/lib/action_dispatch/routing/endpoint.rb +2 -0
  146. data/lib/action_dispatch/routing/inspector.rb +85 -60
  147. data/lib/action_dispatch/routing/mapper.rb +1031 -851
  148. data/lib/action_dispatch/routing/polymorphic_routes.rb +69 -62
  149. data/lib/action_dispatch/routing/redirection.rb +47 -39
  150. data/lib/action_dispatch/routing/route_set.rb +79 -56
  151. data/lib/action_dispatch/routing/routes_proxy.rb +7 -4
  152. data/lib/action_dispatch/routing/url_for.rb +130 -125
  153. data/lib/action_dispatch/routing.rb +150 -148
  154. data/lib/action_dispatch/structured_event_subscriber.rb +20 -0
  155. data/lib/action_dispatch/system_test_case.rb +91 -81
  156. data/lib/action_dispatch/system_testing/browser.rb +16 -23
  157. data/lib/action_dispatch/system_testing/driver.rb +2 -0
  158. data/lib/action_dispatch/system_testing/server.rb +2 -0
  159. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +34 -23
  160. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +2 -0
  161. data/lib/action_dispatch/testing/assertion_response.rb +9 -7
  162. data/lib/action_dispatch/testing/assertions/response.rb +52 -25
  163. data/lib/action_dispatch/testing/assertions/routing.rb +168 -87
  164. data/lib/action_dispatch/testing/assertions.rb +2 -0
  165. data/lib/action_dispatch/testing/integration.rb +233 -223
  166. data/lib/action_dispatch/testing/request_encoder.rb +11 -9
  167. data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +35 -0
  168. data/lib/action_dispatch/testing/test_process.rb +11 -8
  169. data/lib/action_dispatch/testing/test_request.rb +3 -1
  170. data/lib/action_dispatch/testing/test_response.rb +27 -26
  171. data/lib/action_dispatch.rb +36 -32
  172. data/lib/action_pack/gem_version.rb +5 -3
  173. data/lib/action_pack/version.rb +3 -1
  174. data/lib/action_pack.rb +17 -16
  175. metadata +35 -42
  176. data/lib/action_dispatch/journey/parser.y +0 -50
  177. data/lib/action_dispatch/journey/parser_extras.rb +0 -31
data/CHANGELOG.md CHANGED
@@ -1,729 +1,504 @@
1
- ## Rails 7.1.6 (October 28, 2025) ##
1
+ ## Rails 8.1.2 (January 08, 2026) ##
2
2
 
3
- * No changes.
3
+ * Add `config.action_controller.live_streaming_excluded_keys` to control execution state sharing in ActionController::Live.
4
4
 
5
+ When using ActionController::Live, actions are executed in a separate thread that shares
6
+ state from the parent thread. This new configuration allows applications to opt-out specific
7
+ state keys that should not be shared.
5
8
 
6
- ## Rails 7.1.5.2 (August 13, 2025) ##
7
-
8
- * No changes.
9
-
10
-
11
- ## Rails 7.1.5.1 (December 10, 2024) ##
12
-
13
- * Add validation to content security policies to disallow spaces and semicolons.
14
- Developers should use multiple arguments, and different directive methods instead.
15
-
16
- [CVE-2024-54133]
17
-
18
- *Gannon McGibbon*
19
-
20
-
21
- ## Rails 7.1.5 (October 30, 2024) ##
22
-
23
- * No changes.
24
-
25
-
26
- ## Rails 7.1.4.2 (October 23, 2024) ##
27
-
28
- * No changes.
29
-
30
-
31
- ## Rails 7.1.4.1 (October 15, 2024) ##
32
-
33
- * Avoid regex backtracking in HTTP Token authentication
34
-
35
- [CVE-2024-47887]
36
-
37
- *John Hawthorn*
38
-
39
- * Avoid regex backtracking in query parameter filtering
40
-
41
- [CVE-2024-41128]
42
-
43
- *John Hawthorn*
44
-
45
- ## Rails 7.1.4 (August 22, 2024) ##
46
-
47
- * Resolve deprecation warning in latest `selenium-webdriver`.
48
-
49
- *Earlopain*
50
-
51
- * Don't preload Selenium browser when remote.
52
-
53
- *Noah Horton*
54
-
55
- * Fix crash for invalid Content-Type in ShowExceptions middleware.
56
-
57
- *Earlopain*
58
-
59
- * Fix inconsistent results of `params.deep_transform_keys`.
60
-
61
- *Iago Pimenta*
62
-
63
- * Do not report rendered errors except 500.
64
-
65
- *Nikita Vasilevsky*
66
-
67
- * Improve routes source location detection.
68
-
69
- *Jean Boussier*
70
-
71
- * Fix `Request#raw_post` raising `NoMethodError` when `rack.input` is `nil`.
72
-
73
- *Hartley McGuire*
74
-
75
- * Fix url generation in nested engine when script name is empty.
76
-
77
- *zzak*
78
-
79
- * Fix `Mime::Type.parse` handling type parameters for HTTP Accept headers.
80
-
81
- *Taylor Chaparro*
82
-
83
- * Fix the error page that is displayed when a view template is missing to account for nested controller paths in the
84
- suggested correct location for the missing template.
85
-
86
- *Joshua Young*
87
-
88
- * Fix a regression in 7.1.3 passing a `to:` option without a controller when the controller is already defined by a scope.
9
+ This is useful when streaming inside a `connected_to` block, where you may want
10
+ the streaming thread to use its own database connection context.
89
11
 
90
12
  ```ruby
91
- Rails.application.routes.draw do
92
- controller :home do
93
- get "recent", to: "recent_posts"
94
- end
95
- end
13
+ # config/application.rb
14
+ config.action_controller.live_streaming_excluded_keys = [:active_record_connected_to_stack]
96
15
  ```
97
16
 
98
- *Étienne Barrié*
99
-
100
- * Fix `ActionDispatch::Executor` middleware to report errors handled by `ActionDispatch::ShowExceptions`
101
-
102
- In the default production environment, `ShowExceptions` rescues uncaught errors
103
- and returns a response. Because of this the executor wouldn't report production
104
- errors with the default Rails configuration.
17
+ By default, all keys are shared.
105
18
 
106
- *Jean Boussier*
19
+ *Eileen M. Uchitelle*
107
20
 
21
+ * Fix `IpSpoofAttackError` message to include `Forwarded` header content.
108
22
 
109
- ## Rails 7.1.3.4 (June 04, 2024) ##
23
+ Without it, the error message may be misleading.
110
24
 
111
- * Include the HTTP Permissions-Policy on non-HTML Content-Types
112
- [CVE-2024-28103]
25
+ *zzak*
113
26
 
114
- *Aaron Patterson*
115
27
 
116
- ## Rails 7.1.3.3 (May 16, 2024) ##
28
+ ## Rails 8.1.1 (October 28, 2025) ##
117
29
 
118
- * No changes.
30
+ * Allow methods starting with underscore to be action methods.
119
31
 
32
+ Disallowing methods starting with an underscore from being action methods
33
+ was an unintended side effect of the performance optimization in
34
+ 207a254.
120
35
 
121
- ## Rails 7.1.3.2 (February 21, 2024) ##
36
+ Fixes #55985.
122
37
 
123
- * Fix `raise_on_missing_translations` not working correctly with the
124
- `translate` method in controllers after the patch for CVE-2024-26143.
38
+ *Rafael Mendonça França*
125
39
 
126
- *John Hawthorn*
127
40
 
128
- ## Rails 7.1.3.1 (February 21, 2024) ##
41
+ ## Rails 8.1.0 (October 22, 2025) ##
129
42
 
130
- * Fix possible XSS vulnerability with the `translate` method in controllers
43
+ * Submit test requests using `as: :html` with `Content-Type: x-www-form-urlencoded`
131
44
 
132
- CVE-2024-26143
45
+ *Sean Doyle*
133
46
 
134
- *ooooooo-q + Aaron Patterson*
47
+ * Add link-local IP ranges to `ActionDispatch::RemoteIp` default proxies.
135
48
 
136
- * Fix ReDoS in Accept header parsing
49
+ Link-local addresses (`169.254.0.0/16` for IPv4 and `fe80::/10` for IPv6)
50
+ are now included in the default trusted proxy list, similar to private IP ranges.
137
51
 
138
- CVE-2024-26142
52
+ *Adam Daniels*
139
53
 
140
- *Aaron Patterson*
54
+ * `remote_ip` will no longer ignore IPs in X-Forwarded-For headers if they
55
+ are accompanied by port information.
141
56
 
142
- ## Rails 7.1.3 (January 16, 2024) ##
57
+ *Duncan Brown*, *Prevenios Marinos*, *Masafumi Koba*, *Adam Daniels*
143
58
 
144
- * Fix including `Rails.application.routes.url_helpers` directly in an
145
- `ActiveSupport::Concern.`
59
+ * Add `action_dispatch.verbose_redirect_logs` setting that logs where redirects were called from.
146
60
 
147
- *Jonathan Hefner*
61
+ Similar to `active_record.verbose_query_logs` and `active_job.verbose_enqueue_logs`, this adds a line in your logs that shows where a redirect was called from.
148
62
 
149
- * Fix system tests when using a Chrome binary that has been downloaded by
150
- Selenium.
63
+ Example:
151
64
 
152
- *Jonathan Hefner*
65
+ ```
66
+ Redirected to http://localhost:3000/posts/1
67
+ ↳ app/controllers/posts_controller.rb:32:in `block (2 levels) in create'
68
+ ```
153
69
 
70
+ *Dennis Paagman*
154
71
 
155
- ## Rails 7.1.2 (November 10, 2023) ##
72
+ * Add engine route filtering and better formatting in `bin/rails routes`.
156
73
 
157
- * Fix a race condition that could cause a `Text file busy - chromedriver`
158
- error with parallel system tests
74
+ Allow engine routes to be filterable in the routing inspector, and
75
+ improve formatting of engine routing output.
159
76
 
160
- *Matt Brictson*
77
+ Before:
78
+ ```
79
+ > bin/rails routes -e engine_only
80
+ No routes were found for this grep pattern.
81
+ For more information about routes, see the Rails guide: https://guides.rubyonrails.org/routing.html.
82
+ ```
161
83
 
162
- * Fix `StrongParameters#extract_value` to include blank values
84
+ After:
85
+ ```
86
+ > bin/rails routes -e engine_only
87
+ Routes for application:
88
+ No routes were found for this grep pattern.
89
+ For more information about routes, see the Rails guide: https://guides.rubyonrails.org/routing.html.
90
+
91
+ Routes for Test::Engine:
92
+ Prefix Verb URI Pattern Controller#Action
93
+ engine GET /engine_only(.:format) a#b
94
+ ```
163
95
 
164
- Otherwise composite parameters may not be parsed correctly when one of the
165
- component is blank.
96
+ *Dennis Paagman*, *Gannon McGibbon*
166
97
 
167
- *fatkodima*, *Yasha Krasnou*, *Matthias Eiglsperger*
98
+ * Add structured events for Action Pack and Action Dispatch:
99
+ - `action_dispatch.redirect`
100
+ - `action_controller.request_started`
101
+ - `action_controller.request_completed`
102
+ - `action_controller.callback_halted`
103
+ - `action_controller.rescue_from_handled`
104
+ - `action_controller.file_sent`
105
+ - `action_controller.redirected`
106
+ - `action_controller.data_sent`
107
+ - `action_controller.unpermitted_parameters`
108
+ - `action_controller.fragment_cache`
168
109
 
169
- * Add `racc` as a dependency since it will become a bundled gem in Ruby 3.4.0
110
+ *Adrianna Chang*
170
111
 
171
- *Hartley McGuire*
112
+ * URL helpers for engines mounted at the application root handle `SCRIPT_NAME` correctly.
172
113
 
173
- * Support handling Enumerator for non-buffered responses.
114
+ Fixed an issue where `SCRIPT_NAME` is not applied to paths generated for routes in an engine
115
+ mounted at "/".
174
116
 
175
- *Zachary Scott*
117
+ *Mike Dalessio*
176
118
 
119
+ * Update `ActionController::Metal::RateLimiting` to support passing method names to `:by` and `:with`
177
120
 
178
- ## Rails 7.1.1 (October 11, 2023) ##
121
+ ```ruby
122
+ class SignupsController < ApplicationController
123
+ rate_limit to: 10, within: 1.minute, with: :redirect_with_flash
179
124
 
180
- * No changes.
125
+ private
126
+ def redirect_with_flash
127
+ redirect_to root_url, alert: "Too many requests!"
128
+ end
129
+ end
130
+ ```
181
131
 
132
+ *Sean Doyle*
182
133
 
183
- ## Rails 7.1.0 (October 05, 2023) ##
134
+ * Optimize `ActionDispatch::Http::URL.build_host_url` when protocol is included in host.
184
135
 
185
- * No changes.
136
+ When using URL helpers with a host that includes the protocol (e.g., `{ host: "https://example.com" }`),
137
+ skip unnecessary protocol normalization and string duplication since the extracted protocol is already
138
+ in the correct format. This eliminates 2 string allocations per URL generation and provides a ~10%
139
+ performance improvement for this case.
186
140
 
141
+ *Joshua Young*, *Hartley McGuire*
187
142
 
188
- ## Rails 7.1.0.rc2 (October 01, 2023) ##
143
+ * Allow `action_controller.logger` to be disabled by setting it to `nil` or `false` instead of always defaulting to `Rails.logger`.
189
144
 
190
- * No changes.
145
+ *Roberto Miranda*
191
146
 
147
+ * Remove deprecated support to a route to multiple paths.
192
148
 
193
- ## Rails 7.1.0.rc1 (September 27, 2023) ##
149
+ *Rafael Mendonça França*
194
150
 
195
- * Add support for `#deep_merge` and `#deep_merge!` to
196
- `ActionController::Parameters`.
151
+ * Remove deprecated support for using semicolons as a query string separator.
197
152
 
198
- *Sean Doyle*
153
+ Before:
199
154
 
155
+ ```ruby
156
+ ActionDispatch::QueryParser.each_pair("foo=bar;baz=quux").to_a
157
+ # => [["foo", "bar"], ["baz", "quux"]]
158
+ ```
200
159
 
201
- ## Rails 7.1.0.beta1 (September 13, 2023) ##
160
+ After:
202
161
 
203
- * `AbstractController::Translation.raise_on_missing_translations` removed
162
+ ```ruby
163
+ ActionDispatch::QueryParser.each_pair("foo=bar;baz=quux").to_a
164
+ # => [["foo", "bar;baz=quux"]]
165
+ ```
204
166
 
205
- This was a private API, and has been removed in favour of a more broadly applicable
206
- `config.i18n.raise_on_missing_translations`. See the upgrading guide for more information.
167
+ *Rafael Mendonça França*
207
168
 
208
- *Alex Ghiculescu*
169
+ * Remove deprecated support to skipping over leading brackets in parameter names in the parameter parser.
209
170
 
210
- * Add `ActionController::Parameters#extract_value` method to allow extracting serialized values from params
171
+ Before:
211
172
 
212
173
  ```ruby
213
- params = ActionController::Parameters.new(id: "1_123", tags: "ruby,rails")
214
- params.extract_value(:id) # => ["1", "123"]
215
- params.extract_value(:tags, delimiter: ",") # => ["ruby", "rails"]
174
+ ActionDispatch::ParamBuilder.from_query_string("[foo]=bar") # => { "foo" => "bar" }
175
+ ActionDispatch::ParamBuilder.from_query_string("[foo][bar]=baz") # => { "foo" => { "bar" => "baz" } }
216
176
  ```
217
177
 
218
- *Nikita Vasilevsky*
219
-
220
- * Parse JSON `response.parsed_body` with `ActiveSupport::HashWithIndifferentAccess`
221
-
222
- Integrate with Minitest's new `assert_pattern` by parsing the JSON contents
223
- of `response.parsed_body` with `ActiveSupport::HashWithIndifferentAccess`, so
224
- that it's pattern-matching compatible.
225
-
226
- *Sean Doyle*
178
+ After:
227
179
 
228
- * Add support for Playwright as a driver for system tests.
180
+ ```ruby
181
+ ActionDispatch::ParamBuilder.from_query_string("[foo]=bar") # => { "[foo]" => "bar" }
182
+ ActionDispatch::ParamBuilder.from_query_string("[foo][bar]=baz") # => { "[foo]" => { "bar" => "baz" } }
183
+ ```
229
184
 
230
- *Yuki Nishijima*
185
+ *Rafael Mendonça França*
231
186
 
232
- * Fix `HostAuthorization` potentially displaying the value of the
233
- X_FORWARDED_HOST header when the HTTP_HOST header is being blocked.
187
+ * Deprecate `Rails.application.config.action_dispatch.ignore_leading_brackets`.
234
188
 
235
- *Hartley McGuire*, *Daniel Schlosser*
189
+ *Rafael Mendonça França*
236
190
 
237
- * Rename `fixture_file_upload` method to `file_fixture_upload`
191
+ * Raise `ActionController::TooManyRequests` error from `ActionController::RateLimiting`
238
192
 
239
- Declare an alias to preserve the backwards compatibility of `fixture_file_upload`
193
+ Requests that exceed the rate limit raise an `ActionController::TooManyRequests` error.
194
+ By default, Action Dispatch rescues the error and responds with a `429 Too Many Requests` status.
240
195
 
241
196
  *Sean Doyle*
242
197
 
243
- * `ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelper` saves the screenshot path in test metadata on failure.
244
-
245
- *Matija Čupić*
246
-
247
- * `config.dom_testing_default_html_version` controls the HTML parser used by
248
- `ActionDispatch::Assertions#html_document`.
249
-
250
- The Rails 7.1 default configuration opts into the HTML5 parser when it is supported, to better
251
- represent what the DOM would be in a browser user agent. Previously this test helper always used
252
- Nokogiri's HTML4 parser.
253
-
254
- *Mike Dalessio*
255
-
256
- * Ensure an uncaught exception when rendering a Turbo Frame properly breaks
257
- out of the Frame and shows the `DebugView` error page in development.
258
-
259
- *Joé Dupuis*
260
-
261
- * The `with_routing` helper can now be called at the class level. When called at the class level, the routes will
262
- be setup before each test, and reset after every test. For example:
198
+ * Add .md/.markdown as Markdown extensions and add a default `markdown:` renderer:
263
199
 
264
200
  ```ruby
265
- class RoutingTest < ActionController::TestCase
266
- with_routing do |routes|
267
- routes.draw do
268
- resources :articles
269
- resources :authors
270
- end
201
+ class Page
202
+ def to_markdown
203
+ body
271
204
  end
205
+ end
272
206
 
273
- def test_articles_route
274
- assert_routing("/articles", controller: "articles", action: "index")
275
- end
207
+ class PagesController < ActionController::Base
208
+ def show
209
+ @page = Page.find(params[:id])
276
210
 
277
- def test_authors_route
278
- assert_routing("/authors", controller: "authors", action: "index")
211
+ respond_to do |format|
212
+ format.html
213
+ format.md { render markdown: @page }
214
+ end
279
215
  end
280
216
  end
281
217
  ```
282
218
 
283
- *Andrew Novoselac*
219
+ *DHH*
284
220
 
285
- * The `Mime::Type` now supports handling types with parameters and correctly handles quotes.
286
- When parsing the accept header, the parameters before the q-parameter are kept and if a matching mime-type exists it is used.
287
- To keep the current functionality, a fallback is created to look for the media-type without the parameters.
221
+ * Add headers to engine routes inspection command
288
222
 
289
- This change allows for custom MIME-types that are more complex like `application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination/" ext="https://jsonapi.org/ext/atomic"` for the [JSON API](https://jsonapi.org/).
223
+ *Petrik de Heus*
290
224
 
291
- *Nicolas Erni*
225
+ * Add "Copy as text" button to error pages
292
226
 
293
- * The url_for helpers now support a new option called `path_params`.
294
- This is very useful in situations where you only want to add a required param that is part of the route's URL but for other route not append an extraneous query param.
227
+ *Mikkel Malmberg*
295
228
 
296
- Given the following router...
229
+ * Add `scope:` option to `rate_limit` method.
297
230
 
298
- ```ruby
299
- Rails.application.routes.draw do
300
- scope ":account_id" do
301
- get "dashboard" => "pages#dashboard", as: :dashboard
302
- get "search/:term" => "search#search", as: :search
303
- end
304
- delete "signout" => "sessions#destroy", as: :signout
305
- end
306
- ```
231
+ Previously, it was not possible to share a rate limit count between several controllers, since the count was by
232
+ default separate for each controller.
307
233
 
308
- And given the following `ApplicationController`
234
+ Now, the `scope:` option solves this problem.
309
235
 
310
236
  ```ruby
311
- class ApplicationController < ActionController::Base
312
- def default_url_options
313
- { path_params: { account_id: "foo" } }
314
- end
237
+ class APIController < ActionController::API
238
+ rate_limit to: 2, within: 2.seconds, scope: "api"
315
239
  end
316
- ```
317
240
 
318
- The standard url_for helper and friends will now behave as follows:
319
-
320
- ```ruby
321
- dashboard_path # => /foo/dashboard
322
- dashboard_path(account_id: "bar") # => /bar/dashboard
241
+ class API::PostsController < APIController
242
+ # ...
243
+ end
323
244
 
324
- signout_path # => /signout
325
- signout_path(account_id: "bar") # => /signout?account_id=bar
326
- signout_path(account_id: "bar", path_params: { account_id: "baz" }) # => /signout?account_id=bar
327
- search_path("quin") # => /foo/search/quin
245
+ class API::UsersController < APIController
246
+ # ...
247
+ end
328
248
  ```
329
249
 
330
- *Jason Meller, Jeremy Beker*
250
+ *ArthurPV*, *Kamil Hanus*
331
251
 
332
- * Change `action_dispatch.show_exceptions` to one of `:all`, `:rescuable`, or
333
- `:none`. `:all` and `:none` behave the same as the previous `true` and
334
- `false` respectively. The new `:rescuable` option will only show exceptions
335
- that can be rescued (e.g. `ActiveRecord::RecordNotFound`). `:rescuable` is
336
- now the default for the test environment.
252
+ * Add support for `rack.response_finished` callbacks in ActionDispatch::Executor.
337
253
 
338
- *Jon Dufresne*
254
+ The executor middleware now supports deferring completion callbacks to later
255
+ in the request lifecycle by utilizing Rack's `rack.response_finished` mechanism,
256
+ when available. This enables applications to define `rack.response_finished` callbacks
257
+ that may rely on state that would be cleaned up by the executor's completion callbacks.
339
258
 
340
- * `config.action_dispatch.cookies_serializer` now accepts `:message_pack` and
341
- `:message_pack_allow_marshal` as serializers. These serializers require the
342
- [`msgpack` gem](https://rubygems.org/gems/msgpack) (>= 1.7.0).
259
+ *Adrianna Chang*, *Hartley McGuire*
343
260
 
344
- The Message Pack format can provide improved performance and smaller payload
345
- sizes. It also supports roundtripping some Ruby types that are not supported
346
- by JSON. For example:
261
+ * Produce a log when `rescue_from` is invoked.
347
262
 
348
- ```ruby
349
- cookies.encrypted[:foo] = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)]
263
+ *Steven Webb*, *Jean Boussier*
350
264
 
351
- # BEFORE with config.action_dispatch.cookies_serializer = :json
352
- cookies.encrypted[:foo]
353
- # => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"]
354
- cookies.encrypted[:foo].map(&:class)
355
- # => [Hash, Hash, String, String]
265
+ * Allow hosts redirects from `hosts` Rails configuration
356
266
 
357
- # AFTER with config.action_dispatch.cookies_serializer = :message_pack
358
- cookies.encrypted[:foo]
359
- # => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600]
360
- cookies.encrypted[:foo].map(&:class)
361
- # => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time]
362
- ```
267
+ ```ruby
268
+ config.action_controller.allowed_redirect_hosts << "example.com"
269
+ ```
363
270
 
364
- The `:message_pack` serializer can fall back to deserializing with
365
- `ActiveSupport::JSON` when necessary, and the `:message_pack_allow_marshal`
366
- serializer can fall back to deserializing with `Marshal` as well as
367
- `ActiveSupport::JSON`. Additionally, the `:marshal`, `:json`, and
368
- `:json_allow_marshal` (AKA `:hybrid`) serializers can now fall back to
369
- deserializing with `ActiveSupport::MessagePack` when necessary. These
370
- behaviors ensure old cookies can still be read so that migration is easier.
271
+ *Kevin Robatel*
371
272
 
372
- *Jonathan Hefner*
273
+ * `rate_limit.action_controller` notification has additional payload
373
274
 
374
- * Remove leading dot from domains on cookies set with `domain: :all`, to meet RFC6265 requirements
275
+ additional values: count, to, within, by, name, cache_key
375
276
 
376
- *Gareth Adams*
277
+ *Jonathan Rochkind*
377
278
 
378
- * Include source location in routes extended view.
279
+ * Add JSON support to the built-in health controller.
379
280
 
380
- ```bash
381
- $ bin/rails routes --expanded
281
+ The health controller now responds to JSON requests with a structured response
282
+ containing status and timestamp information. This makes it easier for monitoring
283
+ tools and load balancers to consume health check data programmatically.
382
284
 
383
- ...
384
- --[ Route 14 ]----------
385
- Prefix | new_gist
386
- Verb | GET
387
- URI | /gist(.:format)
388
- Controller#Action | gists/gists#new
389
- Source Location | config/routes/gist.rb:3
285
+ ```ruby
286
+ # /up.json
287
+ {
288
+ "status": "up",
289
+ "timestamp": "2025-09-19T12:00:00Z"
290
+ }
390
291
  ```
391
292
 
392
- *Luan Vieira, John Hawthorn and Daniel Colson*
293
+ *Francesco Loreti*, *Juan Vásquez*
393
294
 
394
- * Add `without` as an alias of `except` on `ActiveController::Parameters`.
295
+ * Allow to open source file with a crash from the browser.
395
296
 
396
- *Hidde-Jan Jongsma*
297
+ *Igor Kasyanchuk*
397
298
 
398
- * Expand search field on `rails/info/routes` to also search **route name**, **http verb** and **controller#action**.
299
+ * Always check query string keys for valid encoding just like values are checked.
399
300
 
400
- *Jason Kotchoff*
301
+ *Casper Smits*
401
302
 
402
- * Remove deprecated `poltergeist` and `webkit` (capybara-webkit) driver registration for system testing.
303
+ * Always return empty body for HEAD requests in `PublicExceptions` and
304
+ `DebugExceptions`.
403
305
 
404
- *Rafael Mendonça França*
405
-
406
- * Remove deprecated ability to assign a single value to `config.action_dispatch.trusted_proxies`.
306
+ This is required by `Rack::Lint` (per RFC9110).
407
307
 
408
- *Rafael Mendonça França*
409
-
410
- * Deprecate `config.action_dispatch.return_only_request_media_type_on_content_type`.
411
-
412
- *Rafael Mendonça França*
413
-
414
- * Remove deprecated behavior on `Request#content_type`.
308
+ *Hartley McGuire*
415
309
 
416
- *Rafael Mendonça França*
310
+ * Add comprehensive support for HTTP Cache-Control request directives according to RFC 9111.
417
311
 
418
- * Change `ActionController::Instrumentation` to pass `filtered_path` instead of `fullpath` in the event payload to filter sensitive query params
312
+ Provides a `request.cache_control_directives` object that gives access to request cache directives:
419
313
 
420
314
  ```ruby
421
- get "/posts?password=test"
422
- request.fullpath # => "/posts?password=test"
423
- request.filtered_path # => "/posts?password=[FILTERED]"
315
+ # Boolean directives
316
+ request.cache_control_directives.only_if_cached? # => true/false
317
+ request.cache_control_directives.no_cache? # => true/false
318
+ request.cache_control_directives.no_store? # => true/false
319
+ request.cache_control_directives.no_transform? # => true/false
320
+
321
+ # Value directives
322
+ request.cache_control_directives.max_age # => integer or nil
323
+ request.cache_control_directives.max_stale # => integer or nil (or true for valueless max-stale)
324
+ request.cache_control_directives.min_fresh # => integer or nil
325
+ request.cache_control_directives.stale_if_error # => integer or nil
326
+
327
+ # Special helpers for max-stale
328
+ request.cache_control_directives.max_stale? # => true if max-stale present (with or without value)
329
+ request.cache_control_directives.max_stale_unlimited? # => true only for valueless max-stale
424
330
  ```
425
331
 
426
- *Ritikesh G*
427
-
428
- * Deprecate `AbstractController::Helpers::MissingHelperError`
429
-
430
- *Hartley McGuire*
431
-
432
- * Change `ActionDispatch::Testing::TestResponse#parsed_body` to parse HTML as
433
- a Nokogiri document
332
+ Example usage:
434
333
 
435
334
  ```ruby
436
- get "/posts"
437
- response.content_type # => "text/html; charset=utf-8"
438
- response.parsed_body.class # => Nokogiri::HTML5::Document
439
- response.parsed_body.to_html # => "<!DOCTYPE html>\n<html>\n..."
440
- ```
441
-
442
- *Sean Doyle*
443
-
444
- * Deprecate `ActionDispatch::IllegalStateError`.
445
-
446
- *Samuel Williams*
335
+ def show
336
+ if request.cache_control_directives.only_if_cached?
337
+ @article = Article.find_cached(params[:id])
338
+ return head(:gateway_timeout) if @article.nil?
339
+ else
340
+ @article = Article.find(params[:id])
341
+ end
447
342
 
448
- * Add HTTP::Request#route_uri_pattern that returns URI pattern of matched route.
343
+ render :show
344
+ end
345
+ ```
449
346
 
450
- *Joel Hawksley*, *Kate Higa*
347
+ *egg528*
451
348
 
452
- * Add `ActionDispatch::AssumeSSL` middleware that can be turned on via `config.assume_ssl`.
453
- It makes the application believe that all requests are arriving over SSL. This is useful
454
- when proxying through a load balancer that terminates SSL, the forwarded request will appear
455
- as though its HTTP instead of HTTPS to the application. This makes redirects and cookie
456
- security target HTTP instead of HTTPS. This middleware makes the server assume that the
457
- proxy already terminated SSL, and that the request really is HTTPS.
349
+ * Add assert_in_body/assert_not_in_body as the simplest way to check if a piece of text is in the response body.
458
350
 
459
351
  *DHH*
460
352
 
461
- * Only use HostAuthorization middleware if `config.hosts` is not empty
353
+ * Include cookie name when calculating maximum allowed size.
462
354
 
463
355
  *Hartley McGuire*
464
356
 
465
- * Allow raising an error when a callback's only/unless symbols aren't existing methods.
466
-
467
- When `before_action :callback, only: :action_name` is declared on a controller that doesn't respond to `action_name`, raise an exception at request time. This is a safety measure to ensure that typos or forgetfulness don't prevent a crucial callback from being run when it should.
468
-
469
- For new applications, raising an error for undefined actions is turned on by default. If you do not want to opt-in to this behavior set `config.action_controller.raise_on_missing_callback_actions` to `false` in your application configuration. See #43487 for more details.
470
-
471
- *Jess Bees*
472
-
473
- * Allow cookie options[:domain] to accept a proc to set the cookie domain on a more flexible per-request basis
474
-
475
- *RobL*
476
-
477
- * When a host is not specified for an `ActionController::Renderer`'s env,
478
- the host and related options will now be derived from the routes'
479
- `default_url_options` and `ActionDispatch::Http::URL.secure_protocol`.
480
-
481
- This means that for an application with a configuration like:
482
-
483
- ```ruby
484
- Rails.application.default_url_options = { host: "rubyonrails.org" }
485
- Rails.application.config.force_ssl = true
486
- ```
487
-
488
- rendering a URL like:
489
-
490
- ```ruby
491
- ApplicationController.renderer.render inline: "<%= blog_url %>"
492
- ```
493
-
494
- will now return `"https://rubyonrails.org/blog"` instead of
495
- `"http://example.org/blog"`.
496
-
497
- *Jonathan Hefner*
498
-
499
- * Add details of cookie name and size to `CookieOverflow` exception.
500
-
501
- *Andy Waite*
502
-
503
- * Don't double log the `controller`, `action`, or `namespaced_controller` when using `ActiveRecord::QueryLog`
504
-
505
- Previously if you set `config.active_record.query_log_tags` to an array that included
506
- `:controller`, `:namespaced_controller`, or `:action`, that item would get logged twice.
507
- This bug has been fixed.
508
-
509
- *Alex Ghiculescu*
510
-
511
- * Add the following permissions policy directives: `hid`, `idle-detection`, `screen-wake-lock`,
512
- `serial`, `sync-xhr`, `web-share`.
513
-
514
- *Guillaume Cabanel*
515
-
516
- * The `speaker`, `vibrate`, and `vr` permissions policy directives are now
517
- deprecated.
518
-
519
- There is no browser support for these directives, and no plan for browser
520
- support in the future. You can just remove these directives from your
521
- application.
522
-
523
- *Jonathan Hefner*
524
-
525
- * Added the `:status` option to `assert_redirected_to` to specify the precise
526
- HTTP status of the redirect. Defaults to `:redirect` for backwards
527
- compatibility.
528
-
529
- *Jon Dufresne*
530
-
531
- * Rescue `JSON::ParserError` in Cookies JSON deserializer to discards marshal dumps:
532
-
533
- Without this change, if `action_dispatch.cookies_serializer` is set to `:json` and
534
- the app tries to read a `:marshal` serialized cookie, it would error out which wouldn't
535
- clear the cookie and force app users to manually clear it in their browser.
536
-
537
- (See #45127 for original bug discussion)
357
+ * Implement `must-understand` directive according to RFC 9111.
538
358
 
539
- *Nathan Bardoux*
540
-
541
- * Add `HTTP_REFERER` when following redirects on integration tests
542
-
543
- This makes `follow_redirect!` a closer simulation of what happens in a real browser
544
-
545
- *Felipe Sateler*
546
-
547
- * Added `exclude?` method to `ActionController::Parameters`.
548
-
549
- *Ian Neubert*
550
-
551
- * Rescue `EOFError` exception from `rack` on a multipart request.
552
-
553
- *Nikita Vasilevsky*
554
-
555
- * Log redirects from routes the same way as redirects from controllers.
556
-
557
- *Dennis Paagman*
558
-
559
- * Prevent `ActionDispatch::ServerTiming` from overwriting existing values in `Server-Timing`.
560
- Previously, if another middleware down the chain set `Server-Timing` header,
561
- it would overwritten by `ActionDispatch::ServerTiming`.
562
-
563
- *Jakub Malinowski*
564
-
565
- * Allow opting out of the `SameSite` cookie attribute when setting a cookie.
566
-
567
- You can opt out of `SameSite` by passing `same_site: nil`.
568
-
569
- `cookies[:foo] = { value: "bar", same_site: nil }`
570
-
571
- Previously, this incorrectly set the `SameSite` attribute to the value of the `cookies_same_site_protection` setting.
572
-
573
- *Alex Ghiculescu*
574
-
575
- * Allow using `helper_method`s in `content_security_policy` and `permissions_policy`
576
-
577
- Previously you could access basic helpers (defined in helper modules), but not
578
- helper methods defined using `helper_method`. Now you can use either.
359
+ The `must-understand` directive indicates that a cache must understand the semantics of the response status code, or discard the response. This directive is enforced to be used only with `no-store` to ensure proper cache behavior.
579
360
 
580
361
  ```ruby
581
- content_security_policy do |p|
582
- p.default_src "https://example.com"
583
- p.script_src "https://example.com" if helpers.script_csp?
362
+ class ArticlesController < ApplicationController
363
+ def show
364
+ @article = Article.find(params[:id])
365
+
366
+ if @article.special_format?
367
+ must_understand
368
+ render status: 203 # Non-Authoritative Information
369
+ else
370
+ fresh_when @article
371
+ end
372
+ end
584
373
  end
585
374
  ```
586
375
 
587
- *Alex Ghiculescu*
588
-
589
- * Reimplement `ActionController::Parameters#has_value?` and `#value?` to avoid parameters and hashes comparison.
590
-
591
- Deprecated equality between parameters and hashes is going to be removed in Rails 7.2.
592
- The new implementation takes care of conversions.
593
-
594
- *Seva Stefkin*
595
-
596
- * Allow only String and Symbol keys in `ActionController::Parameters`.
597
- Raise `ActionController::InvalidParameterKey` when initializing Parameters
598
- with keys that aren't strings or symbols.
599
-
600
- *Seva Stefkin*
376
+ *heka1024*
601
377
 
602
- * Add the ability to use custom logic for storing and retrieving CSRF tokens.
378
+ * The JSON renderer doesn't escape HTML entities or Unicode line separators anymore.
603
379
 
604
- By default, the token will be stored in the session. Custom classes can be
605
- defined to specify arbitrary behavior, but the ability to store them in
606
- encrypted cookies is built in.
380
+ Using `render json:` will no longer escape `<`, `>`, `&`, `U+2028` and `U+2029` characters that can cause errors
381
+ when the resulting JSON is embedded in JavaScript, or vulnerabilities when the resulting JSON is embedded in HTML.
607
382
 
608
- *Andrew Kowpak*
383
+ Since the renderer is used to return a JSON document as `application/json`, it's typically not necessary to escape
384
+ those characters, and it improves performance.
609
385
 
610
- * Make ActionController::Parameters#values cast nested hashes into parameters.
386
+ Escaping will still occur when the `:callback` option is set, since the JSON is used as JavaScript code in this
387
+ situation (JSONP).
611
388
 
612
- *Gannon McGibbon*
613
-
614
- * Introduce `html:` and `screenshot:` kwargs for system test screenshot helper
615
-
616
- Use these as an alternative to the already-available environment variables.
617
-
618
- For example, this will display a screenshot in iTerm, save the HTML, and output
619
- its path.
389
+ You can use the `:escape` option or set `config.action_controller.escape_json_responses` to `true` to restore the
390
+ escaping behavior.
620
391
 
621
392
  ```ruby
622
- take_screenshot(html: true, screenshot: "inline")
393
+ class PostsController < ApplicationController
394
+ def index
395
+ render json: Post.last(30), escape: true
396
+ end
397
+ end
623
398
  ```
624
399
 
625
- *Alex Ghiculescu*
626
-
627
- * Allow `ActionController::Parameters#to_h` to receive a block.
400
+ *Étienne Barrié*, *Jean Boussier*
628
401
 
629
- *Bob Farrell*
402
+ * Load lazy route sets before inserting test routes
630
403
 
631
- * Allow relative redirects when `raise_on_open_redirects` is enabled
404
+ Without loading lazy route sets early, we miss `after_routes_loaded` callbacks, or risk
405
+ invoking them with the test routes instead of the real ones if another load is triggered by an engine.
632
406
 
633
- *Tom Hughes*
634
-
635
- * Allow Content Security Policy DSL to generate for API responses.
636
-
637
- *Tim Wade*
407
+ *Gannon McGibbon*
638
408
 
639
- * Fix `authenticate_with_http_basic` to allow for missing password.
409
+ * Raise `AbstractController::DoubleRenderError` if `head` is called after rendering.
640
410
 
641
- Before Rails 7.0 it was possible to handle basic authentication with only a username.
411
+ After this change, invoking `head` will lead to an error if response body is already set:
642
412
 
643
413
  ```ruby
644
- authenticate_with_http_basic do |token, _|
645
- ApiClient.authenticate(token)
414
+ class PostController < ApplicationController
415
+ def index
416
+ render locals: {}
417
+ head :ok
418
+ end
646
419
  end
647
420
  ```
648
421
 
649
- This ability is restored.
650
-
651
- *Jean Boussier*
422
+ *Iaroslav Kurbatov*
652
423
 
653
- * Fix `content_security_policy` returning invalid directives.
424
+ * The Cookie Serializer can now serialize an Active Support SafeBuffer when using message pack.
654
425
 
655
- Directives such as `self`, `unsafe-eval` and few others were not
656
- single quoted when the directive was the result of calling a lambda
657
- returning an array.
426
+ Such code would previously produce an error if an application was using messagepack as its cookie serializer.
658
427
 
659
428
  ```ruby
660
- content_security_policy do |policy|
661
- policy.frame_ancestors lambda { [:self, "https://example.com"] }
429
+ class PostController < ApplicationController
430
+ def index
431
+ flash.notice = t(:hello_html) # This would try to serialize a SafeBuffer, which was not possible.
432
+ end
662
433
  end
663
434
  ```
664
435
 
665
- With this fix the policy generated from above will now be valid.
666
-
667
436
  *Edouard Chin*
668
437
 
669
- * Fix `skip_forgery_protection` to run without raising an error if forgery
670
- protection has not been enabled / `verify_authenticity_token` is not a
671
- defined callback.
438
+ * Fix `Rails.application.reload_routes!` from clearing almost all routes.
672
439
 
673
- This fix prevents the Rails 7.0 Welcome Page (`/`) from raising an
674
- `ArgumentError` if `default_protect_from_forgery` is false.
440
+ When calling `Rails.application.reload_routes!` inside a middleware of
441
+ a Rake task, it was possible under certain conditions that all routes would be cleared.
442
+ If ran inside a middleware, this would result in getting a 404 on most page you visit.
443
+ This issue was only happening in development.
675
444
 
676
- *Brad Trick*
677
-
678
- * Make `redirect_to` return an empty response body.
445
+ *Edouard Chin*
679
446
 
680
- Application controllers that wish to add a response body after calling
681
- `redirect_to` can continue to do so.
447
+ * Add resource name to the `ArgumentError` that's raised when invalid `:only` or `:except` options are given to `#resource` or `#resources`
682
448
 
683
- *Jon Dufresne*
449
+ This makes it easier to locate the source of the problem, especially for routes drawn by gems.
684
450
 
685
- * Use non-capturing group for subdomain matching in `ActionDispatch::HostAuthorization`
451
+ Before:
452
+ ```
453
+ :only and :except must include only [:index, :create, :new, :show, :update, :destroy, :edit], but also included [:foo, :bar]
454
+ ```
686
455
 
687
- Since we do nothing with the captured subdomain group, we can use a non-capturing group instead.
456
+ After:
457
+ ```
458
+ Route `resources :products` - :only and :except must include only [:index, :create, :new, :show, :update, :destroy, :edit], but also included [:foo, :bar]
459
+ ```
688
460
 
689
- *Sam Bostock*
461
+ *Jeremy Green*
690
462
 
691
- * Fix `ActionController::Live` to copy the IsolatedExecutionState in the ephemeral thread.
463
+ * A route pointing to a non-existing controller now returns a 500 instead of a 404.
692
464
 
693
- Since its inception `ActionController::Live` has been copying thread local variables
694
- to keep things such as `CurrentAttributes` set from middlewares working in the controller action.
465
+ A controller not existing isn't a routing error that should result
466
+ in a 404, but a programming error that should result in a 500 and
467
+ be reported.
695
468
 
696
- With the introduction of `IsolatedExecutionState` in 7.0, some of that global state was lost in
697
- `ActionController::Live` controllers.
469
+ Until recently, this was hard to untangle because of the support
470
+ for dynamic `:controller` segment in routes, but since this is
471
+ deprecated and will be removed in Rails 8.1, we can now easily
472
+ not consider missing controllers as routing errors.
698
473
 
699
474
  *Jean Boussier*
700
475
 
701
- * Fix setting `trailing_slash: true` in route definition.
702
-
703
- ```ruby
704
- get '/test' => "test#index", as: :test, trailing_slash: true
705
-
706
- test_path() # => "/test/"
707
- ```
476
+ * Add `check_collisions` option to `ActionDispatch::Session::CacheStore`.
708
477
 
709
- *Jean Boussier*
478
+ Newly generated session ids use 128 bits of randomness, which is more than
479
+ enough to ensure collisions can't happen, but if you need to harden sessions
480
+ even more, you can enable this option to check in the session store that the id
481
+ is indeed free you can enable that option. This however incurs an extra write
482
+ on session creation.
710
483
 
711
- * Make `Session#merge!` stringify keys.
484
+ *Shia*
712
485
 
713
- Previously `Session#update` would, but `merge!` wouldn't.
486
+ * In ExceptionWrapper, match backtrace lines with built templates more often,
487
+ allowing improved highlighting of errors within do-end blocks in templates.
488
+ Fix for Ruby 3.4 to match new method labels in backtrace.
714
489
 
715
- *Drew Bragg*
490
+ *Martin Emde*
716
491
 
717
- * Add `:unsafe_hashes` mapping for `content_security_policy`
492
+ * Allow setting content type with a symbol of the Mime type.
718
493
 
719
494
  ```ruby
720
495
  # Before
721
- policy.script_src :strict_dynamic, "'unsafe-hashes'", "'sha256-rRMdkshZyJlCmDX27XnL7g3zXaxv7ei6Sg+yt4R3svU='"
496
+ response.content_type = "text/html"
722
497
 
723
498
  # After
724
- policy.script_src :strict_dynamic, :unsafe_hashes, "'sha256-rRMdkshZyJlCmDX27XnL7g3zXaxv7ei6Sg+yt4R3svU='"
499
+ response.content_type = :html
725
500
  ```
726
501
 
727
- *Igor Morozov*
502
+ *Petrik de Heus*
728
503
 
729
- Please check [7-0-stable](https://github.com/rails/rails/blob/7-0-stable/actionpack/CHANGELOG.md) for previous changes.
504
+ Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/actionpack/CHANGELOG.md) for previous changes.