actionpack 6.1.7 → 7.0.4

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.

Potentially problematic release.


This version of actionpack might be problematic. Click here for more details.

Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +251 -406
  3. data/MIT-LICENSE +1 -0
  4. data/README.rdoc +2 -3
  5. data/lib/abstract_controller/asset_paths.rb +1 -1
  6. data/lib/abstract_controller/base.rb +13 -26
  7. data/lib/abstract_controller/caching/fragments.rb +2 -2
  8. data/lib/abstract_controller/caching.rb +1 -1
  9. data/lib/abstract_controller/callbacks.rb +21 -7
  10. data/lib/abstract_controller/collector.rb +2 -2
  11. data/lib/abstract_controller/error.rb +1 -1
  12. data/lib/abstract_controller/helpers.rb +4 -3
  13. data/lib/abstract_controller/logger.rb +1 -1
  14. data/lib/abstract_controller/railties/routes_helpers.rb +2 -0
  15. data/lib/abstract_controller/translation.rb +3 -2
  16. data/lib/abstract_controller/url_for.rb +4 -6
  17. data/lib/action_controller/api.rb +6 -6
  18. data/lib/action_controller/base.rb +5 -4
  19. data/lib/action_controller/form_builder.rb +2 -2
  20. data/lib/action_controller/log_subscriber.rb +4 -3
  21. data/lib/action_controller/metal/conditional_get.rb +39 -2
  22. data/lib/action_controller/metal/content_security_policy.rb +36 -2
  23. data/lib/action_controller/metal/cookies.rb +1 -1
  24. data/lib/action_controller/metal/data_streaming.rb +5 -13
  25. data/lib/action_controller/metal/exceptions.rb +19 -30
  26. data/lib/action_controller/metal/flash.rb +6 -2
  27. data/lib/action_controller/metal/helpers.rb +2 -2
  28. data/lib/action_controller/metal/http_authentication.rb +66 -39
  29. data/lib/action_controller/metal/instrumentation.rb +57 -52
  30. data/lib/action_controller/metal/live.rb +43 -2
  31. data/lib/action_controller/metal/mime_responds.rb +3 -3
  32. data/lib/action_controller/metal/params_wrapper.rb +20 -11
  33. data/lib/action_controller/metal/permissions_policy.rb +19 -28
  34. data/lib/action_controller/metal/redirecting.rb +89 -18
  35. data/lib/action_controller/metal/renderers.rb +10 -11
  36. data/lib/action_controller/metal/rendering.rb +8 -8
  37. data/lib/action_controller/metal/request_forgery_protection.rb +78 -29
  38. data/lib/action_controller/metal/rescue.rb +1 -1
  39. data/lib/action_controller/metal/streaming.rb +6 -8
  40. data/lib/action_controller/metal/strong_parameters.rb +100 -54
  41. data/lib/action_controller/metal/testing.rb +9 -2
  42. data/lib/action_controller/metal/url_for.rb +3 -3
  43. data/lib/action_controller/metal.rb +10 -13
  44. data/lib/action_controller/railtie.rb +49 -6
  45. data/lib/action_controller/renderer.rb +1 -1
  46. data/lib/action_controller/test_case.rb +28 -7
  47. data/lib/action_controller.rb +2 -5
  48. data/lib/action_dispatch/http/cache.rb +13 -6
  49. data/lib/action_dispatch/http/content_security_policy.rb +108 -35
  50. data/lib/action_dispatch/http/filter_parameters.rb +5 -0
  51. data/lib/action_dispatch/http/mime_negotiation.rb +15 -5
  52. data/lib/action_dispatch/http/mime_type.rb +9 -11
  53. data/lib/action_dispatch/http/parameters.rb +5 -5
  54. data/lib/action_dispatch/http/permissions_policy.rb +17 -1
  55. data/lib/action_dispatch/http/request.rb +12 -21
  56. data/lib/action_dispatch/http/response.rb +3 -16
  57. data/lib/action_dispatch/http/url.rb +11 -19
  58. data/lib/action_dispatch/journey/gtg/builder.rb +11 -12
  59. data/lib/action_dispatch/journey/gtg/simulator.rb +10 -4
  60. data/lib/action_dispatch/journey/gtg/transition_table.rb +77 -21
  61. data/lib/action_dispatch/journey/nodes/node.rb +70 -5
  62. data/lib/action_dispatch/journey/path/pattern.rb +22 -13
  63. data/lib/action_dispatch/journey/route.rb +6 -13
  64. data/lib/action_dispatch/journey/router/utils.rb +2 -2
  65. data/lib/action_dispatch/journey/router.rb +1 -1
  66. data/lib/action_dispatch/journey/routes.rb +3 -3
  67. data/lib/action_dispatch/journey/visualizer/fsm.js +49 -24
  68. data/lib/action_dispatch/journey/visualizer/index.html.erb +1 -1
  69. data/lib/action_dispatch/middleware/actionable_exceptions.rb +0 -1
  70. data/lib/action_dispatch/middleware/cookies.rb +14 -7
  71. data/lib/action_dispatch/middleware/debug_exceptions.rb +6 -4
  72. data/lib/action_dispatch/middleware/debug_locks.rb +3 -3
  73. data/lib/action_dispatch/middleware/exception_wrapper.rb +4 -0
  74. data/lib/action_dispatch/middleware/executor.rb +3 -0
  75. data/lib/action_dispatch/middleware/flash.rb +17 -18
  76. data/lib/action_dispatch/middleware/host_authorization.rb +1 -12
  77. data/lib/action_dispatch/middleware/remote_ip.rb +16 -4
  78. data/lib/action_dispatch/middleware/request_id.rb +1 -1
  79. data/lib/action_dispatch/middleware/server_timing.rb +76 -0
  80. data/lib/action_dispatch/middleware/session/abstract_store.rb +1 -1
  81. data/lib/action_dispatch/middleware/session/cookie_store.rb +9 -9
  82. data/lib/action_dispatch/middleware/show_exceptions.rb +7 -9
  83. data/lib/action_dispatch/middleware/stack.rb +27 -9
  84. data/lib/action_dispatch/middleware/static.rb +2 -6
  85. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +1 -1
  86. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +4 -11
  87. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +2 -2
  88. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +3 -2
  89. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +2 -0
  90. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +4 -4
  91. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +3 -3
  92. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +28 -18
  93. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +3 -3
  94. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +3 -3
  95. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +3 -3
  96. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +3 -3
  97. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +3 -3
  98. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +5 -14
  99. data/lib/action_dispatch/railtie.rb +8 -2
  100. data/lib/action_dispatch/request/session.rb +43 -13
  101. data/lib/action_dispatch/routing/inspector.rb +1 -1
  102. data/lib/action_dispatch/routing/mapper.rb +59 -83
  103. data/lib/action_dispatch/routing/redirection.rb +5 -2
  104. data/lib/action_dispatch/routing/route_set.rb +17 -7
  105. data/lib/action_dispatch/routing/routes_proxy.rb +1 -1
  106. data/lib/action_dispatch/routing/url_for.rb +4 -5
  107. data/lib/action_dispatch/routing.rb +5 -6
  108. data/lib/action_dispatch/system_test_case.rb +5 -5
  109. data/lib/action_dispatch/system_testing/browser.rb +2 -12
  110. data/lib/action_dispatch/system_testing/driver.rb +35 -11
  111. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +11 -7
  112. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +0 -8
  113. data/lib/action_dispatch/testing/assertions/routing.rb +3 -2
  114. data/lib/action_dispatch/testing/assertions.rb +2 -5
  115. data/lib/action_dispatch/testing/integration.rb +6 -8
  116. data/lib/action_dispatch/testing/test_process.rb +3 -29
  117. data/lib/action_dispatch/testing/test_response.rb +20 -2
  118. data/lib/action_dispatch.rb +1 -0
  119. data/lib/action_pack/gem_version.rb +4 -4
  120. data/lib/action_pack/version.rb +1 -1
  121. metadata +14 -13
data/CHANGELOG.md CHANGED
@@ -1,25 +1,37 @@
1
- ## Rails 6.1.7 (September 09, 2022) ##
1
+ ## Rails 7.0.4 (September 09, 2022) ##
2
2
 
3
- * No changes.
3
+ * Prevent `ActionDispatch::ServerTiming` from overwriting existing values in `Server-Timing`.
4
+
5
+ Previously, if another middleware down the chain set `Server-Timing` header,
6
+ it would overwritten by `ActionDispatch::ServerTiming`.
7
+
8
+ *Jakub Malinowski*
4
9
 
5
10
 
6
- ## Rails 6.1.6.1 (July 12, 2022) ##
11
+ ## Rails 7.0.3.1 (July 12, 2022) ##
7
12
 
8
13
  * No changes.
9
14
 
10
15
 
11
- ## Rails 6.1.6 (May 09, 2022) ##
16
+ ## Rails 7.0.3 (May 09, 2022) ##
12
17
 
13
- * No changes.
18
+ * Allow relative redirects when `raise_on_open_redirects` is enabled.
14
19
 
20
+ *Tom Hughes*
15
21
 
16
- ## Rails 6.1.5.1 (April 26, 2022) ##
22
+ * Fix `authenticate_with_http_basic` to allow for missing password.
17
23
 
18
- * Allow Content Security Policy DSL to generate for API responses.
24
+ Before Rails 7.0 it was possible to handle basic authentication with only a username.
19
25
 
20
- *Tim Wade*
26
+ ```ruby
27
+ authenticate_with_http_basic do |token, _|
28
+ ApiClient.authenticate(token)
29
+ end
30
+ ```
31
+
32
+ This ability is restored.
21
33
 
22
- ## Rails 6.1.5 (March 09, 2022) ##
34
+ *Jean Boussier*
23
35
 
24
36
  * Fix `content_security_policy` returning invalid directives.
25
37
 
@@ -37,53 +49,52 @@
37
49
 
38
50
  *Edouard Chin*
39
51
 
40
- * Update `HostAuthorization` middleware to render debug info only
41
- when `config.consider_all_requests_local` is set to true.
42
-
43
- Also, blocked host info is always logged with level `error`.
44
-
45
- Fixes #42813.
52
+ * Fix `skip_forgery_protection` to run without raising an error if forgery
53
+ protection has not been enabled / `verify_authenticity_token` is not a
54
+ defined callback.
46
55
 
47
- *Nikita Vyrko*
48
-
49
- * Dup arrays that get "converted".
56
+ This fix prevents the Rails 7.0 Welcome Page (`/`) from raising an
57
+ `ArgumentError` if `default_protect_from_forgery` is false.
50
58
 
51
- Fixes #43681.
59
+ *Brad Trick*
52
60
 
53
- *Aaron Patterson*
61
+ * Fix `ActionController::Live` to copy the IsolatedExecutionState in the ephemeral thread.
54
62
 
55
- * Don't show deprecation warning for equal paths.
63
+ Since its inception `ActionController::Live` has been copying thread local variables
64
+ to keep things such as `CurrentAttributes` set from middlewares working in the controller action.
56
65
 
57
- *Anton Rieder*
66
+ With the introduction of `IsolatedExecutionState` in 7.0, some of that global state was lost in
67
+ `ActionController::Live` controllers.
58
68
 
59
- * Fix crash in `ActionController::Instrumentation` with invalid HTTP formats.
69
+ *Jean Boussier*
60
70
 
61
- Fixes #43094.
71
+ * Fix setting `trailing_slash: true` in route definition.
62
72
 
63
- *Alex Ghiculescu*
64
-
65
- * Add fallback host for SystemTestCase driven by RackTest.
73
+ ```ruby
74
+ get '/test' => "test#index", as: :test, trailing_slash: true
66
75
 
67
- Fixes #42780.
76
+ test_path() # => "/test/"
77
+ ```
68
78
 
69
- *Petrik de Heus*
79
+ *Jean Boussier*
70
80
 
71
- * Add more detail about what hosts are allowed.
81
+ ## Rails 7.0.2.4 (April 26, 2022) ##
72
82
 
73
- *Alex Ghiculescu*
83
+ * Allow Content Security Policy DSL to generate for API responses.
74
84
 
85
+ *Tim Wade*
75
86
 
76
- ## Rails 6.1.4.7 (March 08, 2022) ##
87
+ ## Rails 7.0.2.3 (March 08, 2022) ##
77
88
 
78
89
  * No changes.
79
90
 
80
91
 
81
- ## Rails 6.1.4.6 (February 11, 2022) ##
92
+ ## Rails 7.0.2.2 (February 11, 2022) ##
82
93
 
83
94
  * No changes.
84
95
 
85
96
 
86
- ## Rails 6.1.4.5 (February 11, 2022) ##
97
+ ## Rails 7.0.2.1 (February 11, 2022) ##
87
98
 
88
99
  * Under certain circumstances, the middleware isn't informed that the
89
100
  response body has been fully closed which result in request state not
@@ -92,545 +103,379 @@
92
103
  [CVE-2022-23633]
93
104
 
94
105
 
95
- ## Rails 6.1.4.4 (December 15, 2021) ##
96
-
97
- * Fix issue with host protection not allowing host with port in development.
98
-
99
-
100
- ## Rails 6.1.4.3 (December 14, 2021) ##
101
-
102
- * Fix issue with host protection not allowing localhost in development.
103
-
104
-
105
- ## Rails 6.1.4.2 (December 14, 2021) ##
106
-
107
- * Fix X_FORWARDED_HOST protection. [CVE-2021-44528]
108
-
109
- ## Rails 6.1.4.1 (August 19, 2021) ##
110
-
111
- * [CVE-2021-22942] Fix possible open redirect in Host Authorization middleware.
112
-
113
- Specially crafted "X-Forwarded-Host" headers in combination with certain
114
- "allowed host" formats can cause the Host Authorization middleware in Action
115
- Pack to redirect users to a malicious website.
116
-
117
- ## Rails 6.1.4 (June 24, 2021) ##
118
-
119
- * Ignore file fixtures on `db:fixtures:load`
120
-
121
- *Kevin Sjöberg*
122
-
123
- * Fix ActionController::Live controller test deadlocks by removing the body buffer size limit for tests.
124
-
125
- *Dylan Thacker-Smith*
126
-
127
- * Correctly place optional path parameter booleans.
128
-
129
- Previously, if you specify a url parameter that is part of the path as false it would include that part
130
- of the path as parameter for example:
131
-
132
- ```
133
- get "(/optional/:optional_id)/things" => "foo#foo", as: :things
134
- things_path(optional_id: false) # => /things?optional_id=false
135
- ```
136
-
137
- After this change, true and false will be treated the same when used as optional path parameters. Meaning now:
138
-
139
- ```
140
- get '(this/:my_bool)/that' as: :that
141
-
142
- that_path(my_bool: true) # => `/this/true/that`
143
- that_path(my_bool: false) # => `/this/false/that`
144
- ```
145
-
146
- *Adam Hess*
147
-
148
- * Add support for 'private, no-store' Cache-Control headers.
149
-
150
- Previously, 'no-store' was exclusive; no other directives could be specified.
151
-
152
- *Alex Smith*
153
-
154
-
155
- ## Rails 6.1.3.2 (May 05, 2021) ##
156
-
157
- * Prevent open redirects by correctly escaping the host allow list
158
- CVE-2021-22903
159
-
160
- * Prevent catastrophic backtracking during mime parsing
161
- CVE-2021-22902
162
-
163
- * Prevent regex DoS in HTTP token authentication
164
- CVE-2021-22904
165
-
166
- * Prevent string polymorphic route arguments.
167
-
168
- `url_for` supports building polymorphic URLs via an array
169
- of arguments (usually symbols and records). If a developer passes a
170
- user input array, strings can result in unwanted route helper calls.
171
-
172
- CVE-2021-22885
173
-
174
- *Gannon McGibbon*
175
-
176
- ## Rails 6.1.3.1 (March 26, 2021) ##
106
+ ## Rails 7.0.2 (February 08, 2022) ##
177
107
 
178
108
  * No changes.
179
109
 
180
110
 
181
- ## Rails 6.1.3 (February 17, 2021) ##
182
-
183
- * Re-define routes when not set correctly via inheritance.
184
-
185
- *John Hawthorn*
186
-
111
+ ## Rails 7.0.1 (January 06, 2022) ##
187
112
 
188
- ## Rails 6.1.2.1 (February 10, 2021) ##
113
+ * Fix `ActionController::Parameters` methods to keep the original logger context when creating a new copy
114
+ of the original object.
189
115
 
190
- * Prevent open redirect when allowed host starts with a dot
116
+ *Yutaka Kamei*
191
117
 
192
- [CVE-2021-22881]
193
118
 
194
- Thanks to @tktech (https://hackerone.com/tktech) for reporting this
195
- issue and the patch!
119
+ ## Rails 7.0.0 (December 15, 2021) ##
196
120
 
197
- *Aaron Patterson*
121
+ * Deprecate `Rails.application.config.action_controller.urlsafe_csrf_tokens`. This config is now always enabled.
198
122
 
123
+ *Étienne Barrié*
199
124
 
200
- ## Rails 6.1.2 (February 09, 2021) ##
201
-
202
- * Fix error in `ActionController::LogSubscriber` that would happen when throwing inside a controller action.
203
-
204
- *Janko Marohnić*
125
+ * Instance variables set in requests in a `ActionController::TestCase` are now cleared before the next request
205
126
 
206
- * Fix `fixture_file_upload` deprecation when `file_fixture_path` is a relative path.
127
+ This means if you make multiple requests in the same test, instance variables set in the first request will
128
+ not persist into the second one. (It's not recommended to make multiple requests in the same test.)
207
129
 
208
- *Eugene Kenny*
209
-
210
-
211
- ## Rails 6.1.1 (January 07, 2021) ##
212
-
213
- * Fix nil translation key lookup in controllers/
214
-
215
- *Jan Klimo*
130
+ *Alex Ghiculescu*
216
131
 
217
- * Quietly handle unknown HTTP methods in Action Dispatch SSL middleware.
218
132
 
219
- *Alex Robbin*
133
+ ## Rails 7.0.0.rc3 (December 14, 2021) ##
220
134
 
221
- * Change the request method to a `GET` when passing failed requests down to `config.exceptions_app`.
135
+ * No changes.
222
136
 
223
- *Alex Robbin*
224
137
 
138
+ ## Rails 7.0.0.rc2 (December 14, 2021) ##
225
139
 
226
- ## Rails 6.1.0 (December 09, 2020) ##
140
+ * Fix X_FORWARDED_HOST protection. [CVE-2021-44528]
227
141
 
228
- * Support for the HTTP header `Feature-Policy` has been revised to reflect
229
- its [rename](https://github.com/w3c/webappsec-permissions-policy/pull/379) to [`Permissions-Policy`](https://w3c.github.io/webappsec-permissions-policy/#permissions-policy-http-header-field).
230
142
 
231
- ```ruby
232
- Rails.application.config.permissions_policy do |p|
233
- p.camera :none
234
- p.gyroscope :none
235
- p.microphone :none
236
- p.usb :none
237
- p.fullscreen :self
238
- p.payment :self, "https://secure-example.com"
239
- end
240
- ```
143
+ ## Rails 7.0.0.rc1 (December 06, 2021) ##
241
144
 
242
- *Julien Grillot*
145
+ * `Rails.application.executor` hooks can now be called around every request in a `ActionController::TestCase`
243
146
 
244
- * Allow `ActionDispatch::HostAuthorization` to exclude specific requests.
147
+ This helps to better simulate request or job local state being reset between requests and prevent state
148
+ leaking from one request to another.
245
149
 
246
- Host Authorization checks can be skipped for specific requests. This allows for health check requests to be permitted for requests with missing or non-matching host headers.
150
+ To enable this, set `config.active_support.executor_around_test_case = true` (this is the default in Rails 7).
247
151
 
248
- *Chris Bisnett*
152
+ *Alex Ghiculescu*
249
153
 
250
- * Add `config.action_dispatch.request_id_header` to allow changing the name of
251
- the unique X-Request-Id header
154
+ * Consider onion services secure for cookies.
252
155
 
253
- *Arlston Fernandes*
156
+ *Justin Tracey*
254
157
 
255
- * Deprecate `config.action_dispatch.return_only_media_type_on_content_type`.
158
+ * Remove deprecated `Rails.config.action_view.raise_on_missing_translations`.
256
159
 
257
160
  *Rafael Mendonça França*
258
161
 
259
- * Change `ActionDispatch::Response#content_type` to return the full Content-Type header.
162
+ * Remove deprecated support to passing a path to `fixture_file_upload` relative to `fixture_path`.
260
163
 
261
164
  *Rafael Mendonça França*
262
165
 
263
- * Remove deprecated `ActionDispatch::Http::ParameterFilter`.
166
+ * Remove deprecated `ActionDispatch::SystemTestCase#host!`.
264
167
 
265
168
  *Rafael Mendonça França*
266
169
 
267
- * Added support for exclusive no-store Cache-Control header.
268
-
269
- If `no-store` is set on Cache-Control header it is exclusive (all other cache directives are dropped).
270
-
271
- *Chris Kruger*
272
-
273
- * Catch invalid UTF-8 parameters for POST requests and respond with BadRequest.
274
-
275
- Additionally, perform `#set_binary_encoding` in `ActionDispatch::Http::Request#GET` and
276
- `ActionDispatch::Http::Request#POST` prior to validating encoding.
277
-
278
- *Adrianna Chang*
279
-
280
- * Allow `assert_recognizes` routing assertions to work on mounted root routes.
170
+ * Remove deprecated `Rails.config.action_dispatch.hosts_response_app`.
281
171
 
282
- *Gannon McGibbon*
283
-
284
- * Change default redirection status code for non-GET/HEAD requests to 308 Permanent Redirect for `ActionDispatch::SSL`.
285
-
286
- *Alan Tan*, *Oz Ben-David*
287
-
288
- * Fix `follow_redirect!` to follow redirection with same HTTP verb when following
289
- a 308 redirection.
172
+ *Rafael Mendonça França*
290
173
 
291
- *Alan Tan*
174
+ * Remove deprecated `ActionDispatch::Response.return_only_media_type_on_content_type`.
292
175
 
293
- * When multiple domains are specified for a cookie, a domain will now be
294
- chosen only if it is equal to or is a superdomain of the request host.
176
+ *Rafael Mendonça França*
295
177
 
296
- *Jonathan Hefner*
178
+ * Raise `ActionController::Redirecting::UnsafeRedirectError` for unsafe `redirect_to` redirects.
297
179
 
298
- * `ActionDispatch::Static` handles precompiled Brotli (.br) files.
180
+ This allows `rescue_from` to be used to add a default fallback route:
299
181
 
300
- Adds to existing support for precompiled gzip (.gz) files.
301
- Brotli files are preferred due to much better compression.
182
+ ```ruby
183
+ rescue_from ActionController::Redirecting::UnsafeRedirectError do
184
+ redirect_to root_url
185
+ end
186
+ ```
302
187
 
303
- When the browser requests /some.js with `Accept-Encoding: br`,
304
- we check for public/some.js.br and serve that file, if present, with
305
- `Content-Encoding: br` and `Vary: Accept-Encoding` headers.
188
+ *Kasper Timm Hansen*, *Chris Oliver*
306
189
 
307
- *Ryan Edward Hall*, *Jeremy Daer*
190
+ * Add `url_from` to verify a redirect location is internal.
308
191
 
309
- * Add raise_on_missing_translations support for controllers.
192
+ Takes the open redirect protection from `redirect_to` so users can wrap a
193
+ param, and fall back to an alternate redirect URL when the param provided
194
+ one is unsafe.
310
195
 
311
- This configuration determines whether an error should be raised for missing translations.
312
- It can be enabled through `config.i18n.raise_on_missing_translations`. Note that described
313
- configuration also affects raising error for missing translations in views.
196
+ ```ruby
197
+ def create
198
+ redirect_to url_from(params[:redirect_url]) || root_url
199
+ end
200
+ ```
314
201
 
315
- *fatkodima*
202
+ *dmcge*, *Kasper Timm Hansen*
316
203
 
317
- * Added `compact` and `compact!` to `ActionController::Parameters`.
204
+ * Allow Capybara driver name overrides in `SystemTestCase::driven_by`
318
205
 
319
- *Eugene Kenny*
206
+ Allow users to prevent conflicts among drivers that use the same driver
207
+ type (selenium, poltergeist, webkit, rack test).
320
208
 
321
- * Calling `each_pair` or `each_value` on an `ActionController::Parameters`
322
- without passing a block now returns an enumerator.
209
+ Fixes #42502
323
210
 
324
- *Eugene Kenny*
211
+ *Chris LaRose*
325
212
 
326
- * `fixture_file_upload` now uses path relative to `file_fixture_path`
213
+ * Allow multiline to be passed in routes when using wildcard segments.
327
214
 
328
- Previously the path had to be relative to `fixture_path`.
329
- You can change your existing code as follow:
215
+ Previously routes with newlines weren't detected when using wildcard segments, returning
216
+ a `No route matches` error.
217
+ After this change, routes with newlines are detected on wildcard segments. Example
330
218
 
331
219
  ```ruby
332
- # Before
333
- fixture_file_upload('files/dog.png')
220
+ draw do
221
+ get "/wildcard/*wildcard_segment", to: SimpleApp.new("foo#index"), as: :wildcard
222
+ end
334
223
 
335
- # After
336
- fixture_file_upload('dog.png')
224
+ # After the change, the path matches.
225
+ assert_equal "/wildcard/a%0Anewline", url_helpers.wildcard_path(wildcard_segment: "a\nnewline")
337
226
  ```
338
227
 
339
- *Edouard Chin*
228
+ Fixes #39103
340
229
 
341
- * Remove deprecated `force_ssl` at the controller level.
230
+ *Ignacio Chiazzo*
342
231
 
343
- *Rafael Mendonça França*
232
+ * Treat html suffix in controller translation.
344
233
 
345
- * The +helper+ class method for controllers loads helper modules specified as
346
- strings/symbols with `String#constantize` instead of `require_dependency`.
234
+ *Rui Onodera*, *Gavin Miller*
347
235
 
348
- Remember that support for strings/symbols is only a convenient API. You can
349
- always pass a module object:
236
+ * Allow permitting numeric params.
350
237
 
238
+ Previously it was impossible to permit different fields on numeric parameters.
239
+ After this change you can specify different fields for each numbered parameter.
240
+ For example params like,
351
241
  ```ruby
352
- helper UtilsHelper
242
+ book: {
243
+ authors_attributes: {
244
+ '0': { name: "William Shakespeare", age_of_death: "52" },
245
+ '1': { name: "Unattributed Assistant" },
246
+ '2': "Not a hash",
247
+ 'new_record': { name: "Some name" }
248
+ }
249
+ }
353
250
  ```
354
251
 
355
- which is recommended because it is simple and direct. When a string/symbol
356
- is received, `helper` just manipulates and inflects the argument to obtain
357
- that same module object.
252
+ Before you could permit name on each author with,
253
+ `permit book: { authors_attributes: [ :name ] }`
358
254
 
359
- *Xavier Noria*, *Jean Boussier*
255
+ After this change you can permit different keys on each numbered element,
256
+ `permit book: { authors_attributes: { '1': [ :name ], '0': [ :name, :age_of_death ] } }`
360
257
 
361
- * Correctly identify the entire localhost IPv4 range as trusted proxy.
258
+ Fixes #41625
362
259
 
363
- *Nick Soracco*
364
-
365
- * `url_for` will now use "https://" as the default protocol when
366
- `Rails.application.config.force_ssl` is set to true.
367
-
368
- *Jonathan Hefner*
369
-
370
- * Accept and default to base64_urlsafe CSRF tokens.
260
+ *Adam Hess*
371
261
 
372
- Base64 strict-encoded CSRF tokens are not inherently websafe, which makes
373
- them difficult to deal with. For example, the common practice of sending
374
- the CSRF token to a browser in a client-readable cookie does not work properly
375
- out of the box: the value has to be url-encoded and decoded to survive transport.
262
+ * Update `HostAuthorization` middleware to render debug info only
263
+ when `config.consider_all_requests_local` is set to true.
376
264
 
377
- Now, we generate Base64 urlsafe-encoded CSRF tokens, which are inherently safe
378
- to transport. Validation accepts both urlsafe tokens, and strict-encoded tokens
379
- for backwards compatibility.
265
+ Also, blocked host info is always logged with level `error`.
380
266
 
381
- *Scott Blum*
267
+ Fixes #42813
382
268
 
383
- * Support rolling deploys for cookie serialization/encryption changes.
269
+ *Nikita Vyrko*
384
270
 
385
- In a distributed configuration like rolling update, users may observe
386
- both old and new instances during deployment. Users may be served by a
387
- new instance and then by an old instance.
271
+ * Add Server-Timing middleware
388
272
 
389
- That means when the server changes `cookies_serializer` from `:marshal`
390
- to `:hybrid` or the server changes `use_authenticated_cookie_encryption`
391
- from `false` to `true`, users may lose their sessions if they access the
392
- server during deployment.
273
+ Server-Timing specification defines how the server can communicate to browsers performance metrics
274
+ about the request it is responding to.
393
275
 
394
- We added fallbacks to downgrade the cookie format when necessary during
395
- deployment, ensuring compatibility on both old and new instances.
276
+ The ServerTiming middleware is enabled by default on `development` environment by default using the
277
+ `config.server_timing` setting and set the relevant duration metrics in the `Server-Timing` header
396
278
 
397
- *Masaki Hara*
279
+ The full specification for Server-Timing header can be found in: https://www.w3.org/TR/server-timing/#dfn-server-timing-header-field
398
280
 
399
- * `ActionDispatch::Request.remote_ip` has ip address even when all sites are trusted.
281
+ *Sebastian Sogamoso*, *Guillermo Iguaran*
400
282
 
401
- Before, if all `X-Forwarded-For` sites were trusted, the `remote_ip` would default to `127.0.0.1`.
402
- Now, the furthest proxy site is used. e.g.: It now gives an ip address when using curl from the load balancer.
403
283
 
404
- *Keenan Brock*
284
+ ## Rails 7.0.0.alpha2 (September 15, 2021) ##
405
285
 
406
- * Fix possible information leak / session hijacking vulnerability.
286
+ * No changes.
407
287
 
408
- The `ActionDispatch::Session::MemcacheStore` is still vulnerable given it requires the
409
- gem dalli to be updated as well.
410
288
 
411
- CVE-2019-16782.
289
+ ## Rails 7.0.0.alpha1 (September 15, 2021) ##
412
290
 
413
- * Include child session assertion count in ActionDispatch::IntegrationTest.
291
+ * Use a static error message when raising `ActionDispatch::Http::Parameters::ParseError`
292
+ to avoid inadvertently logging the HTTP request body at the `fatal` level when it contains
293
+ malformed JSON.
414
294
 
415
- `IntegrationTest#open_session` uses `dup` to create the new session, which
416
- meant it had its own copy of `@assertions`. This prevented the assertions
417
- from being correctly counted and reported.
295
+ Fixes #41145
418
296
 
419
- Child sessions now have their `attr_accessor` overridden to delegate to the
420
- root session.
297
+ *Aaron Lahey*
421
298
 
422
- Fixes #32142.
299
+ * Add `Middleware#delete!` to delete middleware or raise if not found.
423
300
 
424
- *Sam Bostock*
301
+ `Middleware#delete!` works just like `Middleware#delete` but will
302
+ raise an error if the middleware isn't found.
425
303
 
426
- * Add SameSite protection to every written cookie.
304
+ *Alex Ghiculescu*, *Petrik de Heus*, *Junichi Sato*
427
305
 
428
- Enabling `SameSite` cookie protection is an addition to CSRF protection,
429
- where cookies won't be sent by browsers in cross-site POST requests when set to `:lax`.
306
+ * Raise error on unpermitted open redirects.
430
307
 
431
- `:strict` disables cookies being sent in cross-site GET or POST requests.
308
+ Add `allow_other_host` options to `redirect_to`.
309
+ Opt in to this behaviour with `ActionController::Base.raise_on_open_redirects = true`.
432
310
 
433
- Passing `:none` disables this protection and is the same as previous versions albeit a `; SameSite=None` is appended to the cookie.
311
+ *Gannon McGibbon*
434
312
 
435
- See upgrade instructions in config/initializers/new_framework_defaults_6_1.rb.
313
+ * Deprecate `poltergeist` and `webkit` (capybara-webkit) driver registration for system testing (they will be removed in Rails 7.1). Add `cuprite` instead.
436
314
 
437
- More info [here](https://tools.ietf.org/html/draft-west-first-party-cookies-07)
315
+ [Poltergeist](https://github.com/teampoltergeist/poltergeist) and [capybara-webkit](https://github.com/thoughtbot/capybara-webkit) are already not maintained. These usage in Rails are removed for avoiding confusing users.
438
316
 
439
- _NB: Technically already possible as Rack supports SameSite protection, this is to ensure it's applied to all cookies_
317
+ [Cuprite](https://github.com/rubycdp/cuprite) is a good alternative to Poltergeist. Some guide descriptions are replaced from Poltergeist to Cuprite.
440
318
 
441
- *Cédric Fabianski*
319
+ *Yusuke Iwaki*
442
320
 
443
- * Bring back the feature that allows loading external route files from the router.
321
+ * Exclude additional flash types from `ActionController::Base.action_methods`.
444
322
 
445
- This feature existed back in 2012 but got reverted with the incentive that
446
- https://github.com/rails/routing_concerns was a better approach. Turned out
447
- that this wasn't fully the case and loading external route files from the router
448
- can be helpful for applications with a really large set of routes.
449
- Without this feature, application needs to implement routes reloading
450
- themselves and it's not straightforward.
323
+ Ensures that additional flash types defined on ActionController::Base subclasses
324
+ are not listed as actions on that controller.
451
325
 
452
- ```ruby
453
- # config/routes.rb
326
+ class MyController < ApplicationController
327
+ add_flash_types :hype
328
+ end
454
329
 
455
- Rails.application.routes.draw do
456
- draw(:admin)
457
- end
330
+ MyController.action_methods.include?('hype') # => false
458
331
 
459
- # config/routes/admin.rb
332
+ *Gavin Morrice*
460
333
 
461
- get :foo, to: 'foo#bar'
462
- ```
334
+ * OpenSSL constants are now used for Digest computations.
463
335
 
464
- *Yehuda Katz*, *Edouard Chin*
336
+ *Dirkjan Bussink*
465
337
 
466
- * Fix system test driver option initialization for non-headless browsers.
338
+ * Remove IE6-7-8 file download related hack/fix from ActionController::DataStreaming module.
467
339
 
468
- *glaszig*
340
+ Due to the age of those versions of IE this fix is no longer relevant, more importantly it creates an edge-case for unexpected Cache-Control headers.
469
341
 
470
- * `redirect_to.action_controller` notifications now include the `ActionDispatch::Request` in
471
- their payloads as `:request`.
342
+ *Tadas Sasnauskas*
472
343
 
473
- *Austin Story*
344
+ * Configuration setting to skip logging an uncaught exception backtrace when the exception is
345
+ present in `rescued_responses`.
474
346
 
475
- * `respond_to#any` no longer returns a response's Content-Type based on the
476
- request format but based on the block given.
347
+ It may be too noisy to get all backtraces logged for applications that manage uncaught
348
+ exceptions via `rescued_responses` and `exceptions_app`.
349
+ `config.action_dispatch.log_rescued_responses` (defaults to `true`) can be set to `false` in
350
+ this case, so that only exceptions not found in `rescued_responses` will be logged.
477
351
 
478
- Example:
352
+ *Alexander Azarov*, *Mike Dalessio*
479
353
 
480
- ```ruby
481
- def my_action
482
- respond_to do |format|
483
- format.any { render(json: { foo: 'bar' }) }
484
- end
485
- end
354
+ * Ignore file fixtures on `db:fixtures:load`.
486
355
 
487
- get('my_action.csv')
488
- ```
356
+ *Kevin Sjöberg*
489
357
 
490
- The previous behaviour was to respond with a `text/csv` Content-Type which
491
- is inaccurate since a JSON response is being rendered.
358
+ * Fix ActionController::Live controller test deadlocks by removing the body buffer size limit for tests.
492
359
 
493
- Now it correctly returns a `application/json` Content-Type.
360
+ *Dylan Thacker-Smith*
494
361
 
495
- *Edouard Chin*
362
+ * New `ActionController::ConditionalGet#no_store` method to set HTTP cache control `no-store` directive.
496
363
 
497
- * Replaces (back)slashes in failure screenshot image paths with dashes.
364
+ *Tadas Sasnauskas*
498
365
 
499
- If a failed test case contained a slash or a backslash, a screenshot would be created in a
500
- nested directory, causing issues with `tmp:clear`.
366
+ * Drop support for the `SERVER_ADDR` header.
501
367
 
502
- *Damir Zekic*
368
+ Following up https://github.com/rack/rack/pull/1573 and https://github.com/rails/rails/pull/42349.
503
369
 
504
- * Add `params.member?` to mimic Hash behavior.
370
+ *Ricardo Díaz*
505
371
 
506
- *Younes Serraj*
372
+ * Set session options when initializing a basic session.
507
373
 
508
- * `process_action.action_controller` notifications now include the following in their payloads:
374
+ *Gannon McGibbon*
509
375
 
510
- * `:request` - the `ActionDispatch::Request`
511
- * `:response` - the `ActionDispatch::Response`
376
+ * Add `cache_control: {}` option to `fresh_when` and `stale?`.
512
377
 
513
- *George Claghorn*
378
+ Works as a shortcut to set `response.cache_control` with the above methods.
514
379
 
515
- * Updated `ActionDispatch::Request.remote_ip` setter to clear set the instance
516
- `remote_ip` to `nil` before setting the header that the value is derived
517
- from.
380
+ *Jacopo Beschi*
518
381
 
519
- Fixes #37383.
382
+ * Writing into a disabled session will now raise an error.
520
383
 
521
- *Norm Provost*
384
+ Previously when no session store was set, writing into the session would silently fail.
522
385
 
523
- * `ActionController::Base.log_at` allows setting a different log level per request.
386
+ *Jean Boussier*
524
387
 
525
- ```ruby
526
- # Use the debug level if a particular cookie is set.
527
- class ApplicationController < ActionController::Base
528
- log_at :debug, if: -> { cookies[:debug] }
529
- end
530
- ```
388
+ * Add support for 'require-trusted-types-for' and 'trusted-types' headers.
531
389
 
532
- *George Claghorn*
390
+ Fixes #42034.
533
391
 
534
- * Allow system test screen shots to be taken more than once in
535
- a test by prefixing the file name with an incrementing counter.
392
+ *lfalcao*
536
393
 
537
- Add an environment variable `RAILS_SYSTEM_TESTING_SCREENSHOT_HTML` to
538
- enable saving of HTML during a screenshot in addition to the image.
539
- This uses the same image name, with the extension replaced with `.html`
394
+ * Remove inline styles and address basic accessibility issues on rescue templates.
540
395
 
541
- *Tom Fakes*
396
+ *Jacob Herrington*
542
397
 
543
- * Add `Vary: Accept` header when using `Accept` header for response.
398
+ * Add support for 'private, no-store' Cache-Control headers.
544
399
 
545
- For some requests like `/users/1`, Rails uses requests' `Accept`
546
- header to determine what to return. And if we don't add `Vary`
547
- in the response header, browsers might accidentally cache different
548
- types of content, which would cause issues: e.g. javascript got displayed
549
- instead of html content. This PR fixes these issues by adding `Vary: Accept`
550
- in these types of requests. For more detailed problem description, please read:
400
+ Previously, 'no-store' was exclusive; no other directives could be specified.
551
401
 
552
- https://github.com/rails/rails/pull/36213
402
+ *Alex Smith*
553
403
 
554
- Fixes #25842.
404
+ * Expand payload of `unpermitted_parameters.action_controller` instrumentation to allow subscribers to
405
+ know which controller action received unpermitted parameters.
555
406
 
556
- *Stan Lo*
407
+ *bbuchalter*
557
408
 
558
- * Fix IntegrationTest `follow_redirect!` to follow redirection using the same HTTP verb when following
559
- a 307 redirection.
409
+ * Add `ActionController::Live#send_stream` that makes it more convenient to send generated streams:
560
410
 
561
- *Edouard Chin*
411
+ ```ruby
412
+ send_stream(filename: "subscribers.csv") do |stream|
413
+ stream.writeln "email_address,updated_at"
562
414
 
563
- * System tests require Capybara 3.26 or newer.
415
+ @subscribers.find_each do |subscriber|
416
+ stream.writeln [ subscriber.email_address, subscriber.updated_at ].join(",")
417
+ end
418
+ end
419
+ ```
564
420
 
565
- *George Claghorn*
421
+ *DHH*
566
422
 
567
- * Reduced log noise handling ActionController::RoutingErrors.
423
+ * Add `ActionController::Live::Buffer#writeln` to write a line to the stream with a newline included.
568
424
 
569
- *Alberto Fernández-Capel*
425
+ *DHH*
570
426
 
571
- * Add DSL for configuring HTTP Feature Policy.
427
+ * `ActionDispatch::Request#content_type` now returned Content-Type header as it is.
572
428
 
573
- This new DSL provides a way to configure an HTTP Feature Policy at a
574
- global or per-controller level. Full details of HTTP Feature Policy
575
- specification and guidelines can be found at MDN:
429
+ Previously, `ActionDispatch::Request#content_type` returned value does NOT contain charset part.
430
+ This behavior changed to returned Content-Type header containing charset part as it is.
576
431
 
577
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
432
+ If you want just MIME type, please use `ActionDispatch::Request#media_type` instead.
578
433
 
579
- Example global policy:
434
+ Before:
580
435
 
581
436
  ```ruby
582
- Rails.application.config.feature_policy do |f|
583
- f.camera :none
584
- f.gyroscope :none
585
- f.microphone :none
586
- f.usb :none
587
- f.fullscreen :self
588
- f.payment :self, "https://secure.example.com"
589
- end
437
+ request = ActionDispatch::Request.new("CONTENT_TYPE" => "text/csv; header=present; charset=utf-16", "REQUEST_METHOD" => "GET")
438
+ request.content_type #=> "text/csv"
590
439
  ```
591
440
 
592
- Example controller level policy:
441
+ After:
593
442
 
594
443
  ```ruby
595
- class PagesController < ApplicationController
596
- feature_policy do |p|
597
- p.geolocation "https://example.com"
598
- end
599
- end
444
+ request = ActionDispatch::Request.new("Content-Type" => "text/csv; header=present; charset=utf-16", "REQUEST_METHOD" => "GET")
445
+ request.content_type #=> "text/csv; header=present; charset=utf-16"
446
+ request.media_type #=> "text/csv"
600
447
  ```
601
448
 
602
- *Jacob Bednarz*
449
+ *Rafael Mendonça França*
603
450
 
604
- * Add the ability to set the CSP nonce only to the specified directives.
451
+ * Change `ActionDispatch::Request#media_type` to return `nil` when the request don't have a `Content-Type` header.
605
452
 
606
- Fixes #35137.
453
+ *Rafael Mendonça França*
607
454
 
608
- *Yuji Yaginuma*
455
+ * Fix error in `ActionController::LogSubscriber` that would happen when throwing inside a controller action.
609
456
 
610
- * Keep part when scope option has value.
457
+ *Janko Marohnić*
611
458
 
612
- When a route was defined within an optional scope, if that route didn't
613
- take parameters the scope was lost when using path helpers. This commit
614
- ensures scope is kept both when the route takes parameters or when it
615
- doesn't.
459
+ * Allow anything with `#to_str` (like `Addressable::URI`) as a `redirect_to` location.
616
460
 
617
- Fixes #33219.
461
+ *ojab*
618
462
 
619
- *Alberto Almagro*
463
+ * Change the request method to a `GET` when passing failed requests down to `config.exceptions_app`.
620
464
 
621
- * Added `deep_transform_keys` and `deep_transform_keys!` methods to ActionController::Parameters.
465
+ *Alex Robbin*
622
466
 
623
- *Gustavo Gutierrez*
467
+ * Deprecate the ability to assign a single value to `config.action_dispatch.trusted_proxies`
468
+ as `RemoteIp` middleware behaves inconsistently depending on whether this is configured
469
+ with a single value or an enumerable.
624
470
 
625
- * Calling `ActionController::Parameters#transform_keys`/`!` without a block now returns
626
- an enumerator for the parameters instead of the underlying hash.
471
+ Fixes #40772.
627
472
 
628
- *Eugene Kenny*
473
+ *Christian Sutter*
629
474
 
630
- * Fix strong parameters blocks all attributes even when only some keys are invalid (non-numerical).
631
- It should only block invalid key's values instead.
475
+ * Add `redirect_back_or_to(fallback_location, **)` as a more aesthetically pleasing version of `redirect_back fallback_location:, **`.
476
+ The old method name is retained without explicit deprecation.
632
477
 
633
- *Stan Lo*
478
+ *DHH*
634
479
 
635
480
 
636
- Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionpack/CHANGELOG.md) for previous changes.
481
+ Please check [6-1-stable](https://github.com/rails/rails/blob/6-1-stable/actionpack/CHANGELOG.md) for previous changes.