actionpack 5.2.0 → 6.1.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.
Files changed (156) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +408 -190
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +4 -3
  5. data/lib/abstract_controller/base.rb +38 -4
  6. data/lib/abstract_controller/caching/fragments.rb +6 -22
  7. data/lib/abstract_controller/caching.rb +1 -1
  8. data/lib/abstract_controller/callbacks.rb +14 -2
  9. data/lib/abstract_controller/collector.rb +1 -2
  10. data/lib/abstract_controller/helpers.rb +106 -90
  11. data/lib/abstract_controller/railties/routes_helpers.rb +17 -1
  12. data/lib/abstract_controller/rendering.rb +9 -9
  13. data/lib/abstract_controller/translation.rb +11 -5
  14. data/lib/abstract_controller.rb +2 -0
  15. data/lib/action_controller/api.rb +4 -3
  16. data/lib/action_controller/base.rb +6 -9
  17. data/lib/action_controller/caching.rb +1 -3
  18. data/lib/action_controller/log_subscriber.rb +10 -7
  19. data/lib/action_controller/metal/basic_implicit_render.rb +1 -1
  20. data/lib/action_controller/metal/conditional_get.rb +19 -5
  21. data/lib/action_controller/metal/content_security_policy.rb +1 -2
  22. data/lib/action_controller/metal/cookies.rb +3 -1
  23. data/lib/action_controller/metal/data_streaming.rb +6 -7
  24. data/lib/action_controller/metal/default_headers.rb +17 -0
  25. data/lib/action_controller/metal/etag_with_template_digest.rb +4 -6
  26. data/lib/action_controller/metal/exceptions.rb +56 -2
  27. data/lib/action_controller/metal/flash.rb +5 -5
  28. data/lib/action_controller/metal/head.rb +7 -4
  29. data/lib/action_controller/metal/helpers.rb +14 -5
  30. data/lib/action_controller/metal/http_authentication.rb +25 -24
  31. data/lib/action_controller/metal/implicit_render.rb +5 -15
  32. data/lib/action_controller/metal/instrumentation.rb +13 -14
  33. data/lib/action_controller/metal/live.rb +39 -32
  34. data/lib/action_controller/metal/logging.rb +20 -0
  35. data/lib/action_controller/metal/mime_responds.rb +19 -4
  36. data/lib/action_controller/metal/parameter_encoding.rb +35 -4
  37. data/lib/action_controller/metal/params_wrapper.rb +33 -23
  38. data/lib/action_controller/metal/permissions_policy.rb +46 -0
  39. data/lib/action_controller/metal/redirecting.rb +7 -7
  40. data/lib/action_controller/metal/renderers.rb +4 -4
  41. data/lib/action_controller/metal/rendering.rb +8 -3
  42. data/lib/action_controller/metal/request_forgery_protection.rb +89 -36
  43. data/lib/action_controller/metal/rescue.rb +1 -1
  44. data/lib/action_controller/metal/streaming.rb +0 -1
  45. data/lib/action_controller/metal/strong_parameters.rb +181 -69
  46. data/lib/action_controller/metal/url_for.rb +1 -1
  47. data/lib/action_controller/metal.rb +12 -10
  48. data/lib/action_controller/railties/helpers.rb +1 -1
  49. data/lib/action_controller/renderer.rb +37 -13
  50. data/lib/action_controller/template_assertions.rb +1 -1
  51. data/lib/action_controller/test_case.rb +81 -70
  52. data/lib/action_controller.rb +7 -4
  53. data/lib/action_dispatch/http/cache.rb +34 -28
  54. data/lib/action_dispatch/http/content_disposition.rb +45 -0
  55. data/lib/action_dispatch/http/content_security_policy.rb +47 -24
  56. data/lib/action_dispatch/http/filter_parameters.rb +9 -8
  57. data/lib/action_dispatch/http/filter_redirect.rb +2 -3
  58. data/lib/action_dispatch/http/headers.rb +4 -4
  59. data/lib/action_dispatch/http/mime_negotiation.rb +31 -13
  60. data/lib/action_dispatch/http/mime_type.rb +43 -24
  61. data/lib/action_dispatch/http/parameters.rb +14 -23
  62. data/lib/action_dispatch/http/permissions_policy.rb +173 -0
  63. data/lib/action_dispatch/http/request.rb +45 -22
  64. data/lib/action_dispatch/http/response.rb +45 -25
  65. data/lib/action_dispatch/http/upload.rb +9 -1
  66. data/lib/action_dispatch/http/url.rb +82 -82
  67. data/lib/action_dispatch/journey/formatter.rb +55 -31
  68. data/lib/action_dispatch/journey/gtg/builder.rb +22 -37
  69. data/lib/action_dispatch/journey/gtg/simulator.rb +8 -7
  70. data/lib/action_dispatch/journey/gtg/transition_table.rb +6 -5
  71. data/lib/action_dispatch/journey/nfa/dot.rb +0 -11
  72. data/lib/action_dispatch/journey/nodes/node.rb +13 -11
  73. data/lib/action_dispatch/journey/parser.rb +13 -13
  74. data/lib/action_dispatch/journey/parser.y +1 -1
  75. data/lib/action_dispatch/journey/path/pattern.rb +21 -22
  76. data/lib/action_dispatch/journey/route.rb +10 -20
  77. data/lib/action_dispatch/journey/router/utils.rb +14 -12
  78. data/lib/action_dispatch/journey/router.rb +26 -34
  79. data/lib/action_dispatch/journey/routes.rb +1 -2
  80. data/lib/action_dispatch/journey/scanner.rb +10 -4
  81. data/lib/action_dispatch/journey/visitors.rb +1 -4
  82. data/lib/action_dispatch/journey.rb +0 -2
  83. data/lib/action_dispatch/middleware/actionable_exceptions.rb +46 -0
  84. data/lib/action_dispatch/middleware/callbacks.rb +2 -4
  85. data/lib/action_dispatch/middleware/cookies.rb +128 -109
  86. data/lib/action_dispatch/middleware/debug_exceptions.rb +43 -66
  87. data/lib/action_dispatch/middleware/debug_locks.rb +5 -5
  88. data/lib/action_dispatch/middleware/debug_view.rb +66 -0
  89. data/lib/action_dispatch/middleware/exception_wrapper.rb +75 -30
  90. data/lib/action_dispatch/middleware/flash.rb +2 -2
  91. data/lib/action_dispatch/middleware/host_authorization.rb +130 -0
  92. data/lib/action_dispatch/middleware/public_exceptions.rb +6 -3
  93. data/lib/action_dispatch/middleware/remote_ip.rb +14 -16
  94. data/lib/action_dispatch/middleware/request_id.rb +5 -6
  95. data/lib/action_dispatch/middleware/session/abstract_store.rb +15 -2
  96. data/lib/action_dispatch/middleware/session/cache_store.rb +11 -6
  97. data/lib/action_dispatch/middleware/session/cookie_store.rb +24 -19
  98. data/lib/action_dispatch/middleware/show_exceptions.rb +3 -2
  99. data/lib/action_dispatch/middleware/ssl.rb +20 -15
  100. data/lib/action_dispatch/middleware/stack.rb +57 -3
  101. data/lib/action_dispatch/middleware/static.rb +153 -93
  102. data/lib/action_dispatch/middleware/templates/rescues/_actions.html.erb +13 -0
  103. data/lib/action_dispatch/middleware/templates/rescues/_actions.text.erb +0 -0
  104. data/lib/action_dispatch/middleware/templates/rescues/_message_and_suggestions.html.erb +22 -0
  105. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb +3 -1
  106. data/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb +1 -1
  107. data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +4 -2
  108. data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +45 -35
  109. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +7 -0
  110. data/lib/action_dispatch/middleware/templates/rescues/blocked_host.text.erb +5 -0
  111. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +23 -4
  112. data/lib/action_dispatch/middleware/templates/rescues/diagnostics.text.erb +1 -1
  113. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +6 -3
  114. data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +4 -1
  115. data/lib/action_dispatch/middleware/templates/rescues/layout.erb +104 -8
  116. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +19 -0
  117. data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.text.erb +3 -0
  118. data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +2 -2
  119. data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +1 -1
  120. data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +2 -2
  121. data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -1
  122. data/lib/action_dispatch/middleware/templates/routes/_table.html.erb +24 -1
  123. data/lib/action_dispatch/railtie.rb +8 -2
  124. data/lib/action_dispatch/request/session.rb +17 -10
  125. data/lib/action_dispatch/request/utils.rb +28 -2
  126. data/lib/action_dispatch/routing/inspector.rb +101 -53
  127. data/lib/action_dispatch/routing/mapper.rb +156 -103
  128. data/lib/action_dispatch/routing/polymorphic_routes.rb +21 -19
  129. data/lib/action_dispatch/routing/redirection.rb +4 -4
  130. data/lib/action_dispatch/routing/route_set.rb +71 -69
  131. data/lib/action_dispatch/routing/url_for.rb +3 -3
  132. data/lib/action_dispatch/routing.rb +21 -20
  133. data/lib/action_dispatch/system_test_case.rb +54 -11
  134. data/lib/action_dispatch/system_testing/browser.rb +53 -16
  135. data/lib/action_dispatch/system_testing/driver.rb +11 -3
  136. data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +49 -7
  137. data/lib/action_dispatch/system_testing/test_helpers/setup_and_teardown.rb +8 -6
  138. data/lib/action_dispatch/testing/assertion_response.rb +0 -1
  139. data/lib/action_dispatch/testing/assertions/response.rb +4 -7
  140. data/lib/action_dispatch/testing/assertions/routing.rb +20 -8
  141. data/lib/action_dispatch/testing/assertions.rb +1 -1
  142. data/lib/action_dispatch/testing/integration.rb +61 -28
  143. data/lib/action_dispatch/testing/request_encoder.rb +3 -3
  144. data/lib/action_dispatch/testing/test_process.rb +29 -4
  145. data/lib/action_dispatch/testing/test_request.rb +3 -3
  146. data/lib/action_dispatch/testing/test_response.rb +4 -32
  147. data/lib/action_dispatch.rb +14 -7
  148. data/lib/action_pack/gem_version.rb +3 -3
  149. data/lib/action_pack.rb +1 -1
  150. metadata +39 -22
  151. data/lib/action_controller/metal/force_ssl.rb +0 -99
  152. data/lib/action_dispatch/http/parameter_filter.rb +0 -86
  153. data/lib/action_dispatch/journey/nfa/builder.rb +0 -78
  154. data/lib/action_dispatch/journey/nfa/simulator.rb +0 -49
  155. data/lib/action_dispatch/journey/nfa/transition_table.rb +0 -120
  156. data/lib/action_dispatch/system_testing/test_helpers/undef_methods.rb +0 -26
data/CHANGELOG.md CHANGED
@@ -1,302 +1,520 @@
1
- ## Rails 5.2.0 (April 09, 2018) ##
1
+ ## Rails 6.1.4 (June 24, 2021) ##
2
2
 
3
- * Check exclude before flagging cookies as secure.
3
+ * Ignore file fixtures on `db:fixtures:load`
4
4
 
5
- *Catherine Khuu*
5
+ *Kevin Sjöberg*
6
6
 
7
- * Always yield a CSP policy instance from `content_security_policy`
7
+ * Fix ActionController::Live controller test deadlocks by removing the body buffer size limit for tests.
8
8
 
9
- This allows a controller action to enable the policy individually
10
- for a controller and/or specific actions.
9
+ *Dylan Thacker-Smith*
11
10
 
12
- *Andrew White*
11
+ * Correctly place optional path parameter booleans.
13
12
 
14
- * Add the ability to disable the global CSP in a controller, e.g:
13
+ Previously, if you specify a url parameter that is part of the path as false it would include that part
14
+ of the path as parameter for example:
15
15
 
16
- class LegacyPagesController < ApplicationController
17
- content_security_policy false, only: :index
18
- end
16
+ ```
17
+ get "(/optional/:optional_id)/things" => "foo#foo", as: :things
18
+ things_path(optional_id: false) # => /things?optional_id=false
19
+ ```
19
20
 
20
- *Andrew White*
21
+ After this change, true and false will be treated the same when used as optional path parameters. Meaning now:
21
22
 
22
- * Add alias method `to_hash` to `to_h` for `cookies`.
23
- Add alias method `to_h` to `to_hash` for `session`.
23
+ ```
24
+ get '(this/:my_bool)/that' as: :that
24
25
 
25
- *Igor Kasyanchuk*
26
+ that_path(my_bool: true) # => `/this/true/that`
27
+ that_path(my_bool: false) # => `/this/false/that`
28
+ ```
26
29
 
27
- * Update the default HSTS max-age value to 31536000 seconds (1 year)
28
- to meet the minimum max-age requirement for https://hstspreload.org/.
30
+ *Adam Hess*
29
31
 
30
- *Grant Bourque*
32
+ * Add support for 'private, no-store' Cache-Control headers.
31
33
 
32
- * Add support for automatic nonce generation for Rails UJS.
34
+ Previously, 'no-store' was exclusive; no other directives could be specified.
33
35
 
34
- Because the UJS library creates a script tag to process responses it
35
- normally requires the script-src attribute of the content security
36
- policy to include 'unsafe-inline'.
36
+ *Alex Smith*
37
37
 
38
- To work around this we generate a per-request nonce value that is
39
- embedded in a meta tag in a similar fashion to how CSRF protection
40
- embeds its token in a meta tag. The UJS library can then read the
41
- nonce value and set it on the dynamically generated script tag to
42
- enable it to execute without needing 'unsafe-inline' enabled.
43
38
 
44
- Nonce generation isn't 100% safe - if your script tag is including
45
- user generated content in someway then it may be possible to exploit
46
- an XSS vulnerability which can take advantage of the nonce. It is
47
- however an improvement on a blanket permission for inline scripts.
39
+ ## Rails 6.1.3.2 (May 05, 2021) ##
48
40
 
49
- It is also possible to use the nonce within your own script tags by
50
- using `nonce: true` to set the nonce value on the tag, e.g
41
+ * Prevent open redirects by correctly escaping the host allow list
42
+ CVE-2021-22903
51
43
 
52
- <%= javascript_tag nonce: true do %>
53
- alert('Hello, World!');
54
- <% end %>
44
+ * Prevent catastrophic backtracking during mime parsing
45
+ CVE-2021-22902
55
46
 
56
- Fixes #31689.
47
+ * Prevent regex DoS in HTTP token authentication
48
+ CVE-2021-22904
57
49
 
58
- *Andrew White*
50
+ * Prevent string polymorphic route arguments.
59
51
 
60
- * Matches behavior of `Hash#each` in `ActionController::Parameters#each`.
52
+ `url_for` supports building polymorphic URLs via an array
53
+ of arguments (usually symbols and records). If a developer passes a
54
+ user input array, strings can result in unwanted route helper calls.
61
55
 
62
- *Dominic Cleal*
56
+ CVE-2021-22885
63
57
 
64
- * Add `Referrer-Policy` header to default headers set.
58
+ *Gannon McGibbon*
65
59
 
66
- *Guillermo Iguaran*
60
+ ## Rails 6.1.3.1 (March 26, 2021) ##
67
61
 
68
- * Changed the system tests to set Puma as default server only when the
69
- user haven't specified manually another server.
62
+ * No changes.
70
63
 
71
- *Guillermo Iguaran*
72
64
 
73
- * Add secure `X-Download-Options` and `X-Permitted-Cross-Domain-Policies` to
74
- default headers set.
65
+ ## Rails 6.1.3 (February 17, 2021) ##
75
66
 
76
- *Guillermo Iguaran*
67
+ * Re-define routes when not set correctly via inheritance.
77
68
 
78
- * Add headless firefox support to System Tests.
69
+ *John Hawthorn*
79
70
 
80
- *bogdanvlviv*
81
71
 
82
- * Changed the default system test screenshot output from `inline` to `simple`.
72
+ ## Rails 6.1.2.1 (February 10, 2021) ##
83
73
 
84
- `inline` works well for iTerm2 but not everyone uses iTerm2. Some terminals like
85
- Terminal.app ignore the `inline` and output the path to the file since it can't
86
- render the image. Other terminals, like those on Ubuntu, cannot handle the image
87
- inline, but also don't handle it gracefully and instead of outputting the file
88
- path, it dumps binary into the terminal.
74
+ * Prevent open redirect when allowed host starts with a dot
89
75
 
90
- Commit 9d6e28 fixes this by changing the default for screenshot to be `simple`.
76
+ [CVE-2021-22881]
91
77
 
92
- *Eileen M. Uchitelle*
78
+ Thanks to @tktech (https://hackerone.com/tktech) for reporting this
79
+ issue and the patch!
93
80
 
94
- * Register most popular audio/video/font mime types supported by modern browsers.
81
+ *Aaron Patterson*
95
82
 
96
- *Guillermo Iguaran*
97
83
 
98
- * Fix optimized url helpers when using relative url root.
84
+ ## Rails 6.1.2 (February 09, 2021) ##
99
85
 
100
- Fixes #31220.
86
+ * Fix error in `ActionController::LogSubscriber` that would happen when throwing inside a controller action.
101
87
 
102
- *Andrew White*
88
+ *Janko Marohnić*
103
89
 
104
- * Add DSL for configuring Content-Security-Policy header.
90
+ * Fix `fixture_file_upload` deprecation when `file_fixture_path` is a relative path.
105
91
 
106
- The DSL allows you to configure a global Content-Security-Policy
107
- header and then override within a controller. For more information
108
- about the Content-Security-Policy header see MDN:
92
+ *Eugene Kenny*
109
93
 
110
- https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
111
94
 
112
- Example global policy:
95
+ ## Rails 6.1.1 (January 07, 2021) ##
113
96
 
114
- # config/initializers/content_security_policy.rb
115
- Rails.application.config.content_security_policy do |p|
116
- p.default_src :self, :https
117
- p.font_src :self, :https, :data
118
- p.img_src :self, :https, :data
119
- p.object_src :none
120
- p.script_src :self, :https
121
- p.style_src :self, :https, :unsafe_inline
122
- end
97
+ * Fix nil translation key lookup in controllers/
123
98
 
124
- Example controller overrides:
99
+ *Jan Klimo*
125
100
 
126
- # Override policy inline
127
- class PostsController < ApplicationController
128
- content_security_policy do |p|
129
- p.upgrade_insecure_requests true
130
- end
131
- end
101
+ * Quietly handle unknown HTTP methods in Action Dispatch SSL middleware.
132
102
 
133
- # Using literal values
134
- class PostsController < ApplicationController
135
- content_security_policy do |p|
136
- p.base_uri "https://www.example.com"
137
- end
138
- end
103
+ *Alex Robbin*
139
104
 
140
- # Using mixed static and dynamic values
141
- class PostsController < ApplicationController
142
- content_security_policy do |p|
143
- p.base_uri :self, -> { "https://#{current_user.domain}.example.com" }
144
- end
145
- end
105
+ * Change the request method to a `GET` when passing failed requests down to `config.exceptions_app`.
146
106
 
147
- Allows you to also only report content violations for migrating
148
- legacy content using the `content_security_policy_report_only`
149
- configuration attribute, e.g;
107
+ *Alex Robbin*
150
108
 
151
- # config/initializers/content_security_policy.rb
152
- Rails.application.config.content_security_policy_report_only = true
153
109
 
154
- # controller override
155
- class PostsController < ApplicationController
156
- content_security_policy_report_only only: :index
157
- end
110
+ ## Rails 6.1.0 (December 09, 2020) ##
158
111
 
159
- Note that this feature does not validate the header for performance
160
- reasons since the header is calculated at runtime.
112
+ * Support for the HTTP header `Feature-Policy` has been revised to reflect
113
+ 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).
161
114
 
162
- *Andrew White*
115
+ ```ruby
116
+ Rails.application.config.permissions_policy do |p|
117
+ p.camera :none
118
+ p.gyroscope :none
119
+ p.microphone :none
120
+ p.usb :none
121
+ p.fullscreen :self
122
+ p.payment :self, "https://secure-example.com"
123
+ end
124
+ ```
163
125
 
164
- * Make `assert_recognizes` to traverse mounted engines.
126
+ *Julien Grillot*
165
127
 
166
- *Yuichiro Kaneko*
128
+ * Allow `ActionDispatch::HostAuthorization` to exclude specific requests.
167
129
 
168
- * Remove deprecated `ActionController::ParamsParser::ParseError`.
130
+ 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.
131
+
132
+ *Chris Bisnett*
133
+
134
+ * Add `config.action_dispatch.request_id_header` to allow changing the name of
135
+ the unique X-Request-Id header
136
+
137
+ *Arlston Fernandes*
138
+
139
+ * Deprecate `config.action_dispatch.return_only_media_type_on_content_type`.
169
140
 
170
141
  *Rafael Mendonça França*
171
142
 
172
- * Add `:allow_other_host` option to `redirect_back` method.
143
+ * Change `ActionDispatch::Response#content_type` to return the full Content-Type header.
173
144
 
174
- When `allow_other_host` is set to `false`, the `redirect_back` will not allow redirecting from a
175
- different host. `allow_other_host` is `true` by default.
145
+ *Rafael Mendonça França*
176
146
 
177
- *Tim Masliuchenko*
147
+ * Remove deprecated `ActionDispatch::Http::ParameterFilter`.
178
148
 
179
- * Add headless chrome support to System Tests.
149
+ *Rafael Mendonça França*
180
150
 
181
- *Yuji Yaginuma*
151
+ * Added support for exclusive no-store Cache-Control header.
182
152
 
183
- * Add ability to enable Early Hints for HTTP/2
153
+ If `no-store` is set on Cache-Control header it is exclusive (all other cache directives are dropped).
184
154
 
185
- If supported by the server, and enabled in Puma this allows H2 Early Hints to be used.
155
+ *Chris Kruger*
186
156
 
187
- The `javascript_include_tag` and the `stylesheet_link_tag` automatically add Early Hints if requested.
157
+ * Catch invalid UTF-8 parameters for POST requests and respond with BadRequest.
188
158
 
189
- *Eileen M. Uchitelle*, *Aaron Patterson*
159
+ Additionally, perform `#set_binary_encoding` in `ActionDispatch::Http::Request#GET` and
160
+ `ActionDispatch::Http::Request#POST` prior to validating encoding.
190
161
 
191
- * Simplify cookies middleware with key rotation support
162
+ *Adrianna Chang*
192
163
 
193
- Use the `rotate` method for both `MessageEncryptor` and
194
- `MessageVerifier` to add key rotation support for encrypted and
195
- signed cookies. This also helps simplify support for legacy cookie
196
- security.
164
+ * Allow `assert_recognizes` routing assertions to work on mounted root routes.
197
165
 
198
- *Michael J Coyne*
166
+ *Gannon McGibbon*
199
167
 
200
- * Use Capybara registered `:puma` server config.
168
+ * Change default redirection status code for non-GET/HEAD requests to 308 Permanent Redirect for `ActionDispatch::SSL`.
201
169
 
202
- The Capybara registered `:puma` server ensures the puma server is run in process so
203
- connection sharing and open request detection work correctly by default.
170
+ *Alan Tan*, *Oz Ben-David*
204
171
 
205
- *Thomas Walpole*
172
+ * Fix `follow_redirect!` to follow redirection with same HTTP verb when following
173
+ a 308 redirection.
206
174
 
207
- * Cookies `:expires` option supports `ActiveSupport::Duration` object.
175
+ *Alan Tan*
208
176
 
209
- cookies[:user_name] = { value: "assain", expires: 1.hour }
210
- cookies[:key] = { value: "a yummy cookie", expires: 6.months }
177
+ * When multiple domains are specified for a cookie, a domain will now be
178
+ chosen only if it is equal to or is a superdomain of the request host.
211
179
 
212
- Pull Request: #30121
180
+ *Jonathan Hefner*
213
181
 
214
- *Assain Jaleel*
182
+ * `ActionDispatch::Static` handles precompiled Brotli (.br) files.
215
183
 
216
- * Enforce signed/encrypted cookie expiry server side.
184
+ Adds to existing support for precompiled gzip (.gz) files.
185
+ Brotli files are preferred due to much better compression.
217
186
 
218
- Rails can thwart attacks by malicious clients that don't honor a cookie's expiry.
187
+ When the browser requests /some.js with `Accept-Encoding: br`,
188
+ we check for public/some.js.br and serve that file, if present, with
189
+ `Content-Encoding: br` and `Vary: Accept-Encoding` headers.
219
190
 
220
- It does so by stashing the expiry within the written cookie and relying on the
221
- signing/encrypting to vouch that it hasn't been tampered with. Then on a
222
- server-side read, the expiry is verified and any expired cookie is discarded.
191
+ *Ryan Edward Hall*, *Jeremy Daer*
223
192
 
224
- Pull Request: #30121
193
+ * Add raise_on_missing_translations support for controllers.
225
194
 
226
- *Assain Jaleel*
195
+ This configuration determines whether an error should be raised for missing translations.
196
+ It can be enabled through `config.i18n.raise_on_missing_translations`. Note that described
197
+ configuration also affects raising error for missing translations in views.
227
198
 
228
- * Make `take_failed_screenshot` work within engine.
199
+ *fatkodima*
229
200
 
230
- Fixes #30405.
201
+ * Added `compact` and `compact!` to `ActionController::Parameters`.
231
202
 
232
- *Yuji Yaginuma*
203
+ *Eugene Kenny*
204
+
205
+ * Calling `each_pair` or `each_value` on an `ActionController::Parameters`
206
+ without passing a block now returns an enumerator.
207
+
208
+ *Eugene Kenny*
209
+
210
+ * `fixture_file_upload` now uses path relative to `file_fixture_path`
211
+
212
+ Previously the path had to be relative to `fixture_path`.
213
+ You can change your existing code as follow:
214
+
215
+ ```ruby
216
+ # Before
217
+ fixture_file_upload('files/dog.png')
218
+
219
+ # After
220
+ fixture_file_upload('dog.png')
221
+ ```
222
+
223
+ *Edouard Chin*
224
+
225
+ * Remove deprecated `force_ssl` at the controller level.
226
+
227
+ *Rafael Mendonça França*
228
+
229
+ * The +helper+ class method for controllers loads helper modules specified as
230
+ strings/symbols with `String#constantize` instead of `require_dependency`.
231
+
232
+ Remember that support for strings/symbols is only a convenient API. You can
233
+ always pass a module object:
234
+
235
+ ```ruby
236
+ helper UtilsHelper
237
+ ```
238
+
239
+ which is recommended because it is simple and direct. When a string/symbol
240
+ is received, `helper` just manipulates and inflects the argument to obtain
241
+ that same module object.
242
+
243
+ *Xavier Noria*, *Jean Boussier*
244
+
245
+ * Correctly identify the entire localhost IPv4 range as trusted proxy.
246
+
247
+ *Nick Soracco*
248
+
249
+ * `url_for` will now use "https://" as the default protocol when
250
+ `Rails.application.config.force_ssl` is set to true.
251
+
252
+ *Jonathan Hefner*
253
+
254
+ * Accept and default to base64_urlsafe CSRF tokens.
255
+
256
+ Base64 strict-encoded CSRF tokens are not inherently websafe, which makes
257
+ them difficult to deal with. For example, the common practice of sending
258
+ the CSRF token to a browser in a client-readable cookie does not work properly
259
+ out of the box: the value has to be url-encoded and decoded to survive transport.
260
+
261
+ Now, we generate Base64 urlsafe-encoded CSRF tokens, which are inherently safe
262
+ to transport. Validation accepts both urlsafe tokens, and strict-encoded tokens
263
+ for backwards compatibility.
264
+
265
+ *Scott Blum*
266
+
267
+ * Support rolling deploys for cookie serialization/encryption changes.
268
+
269
+ In a distributed configuration like rolling update, users may observe
270
+ both old and new instances during deployment. Users may be served by a
271
+ new instance and then by an old instance.
272
+
273
+ That means when the server changes `cookies_serializer` from `:marshal`
274
+ to `:hybrid` or the server changes `use_authenticated_cookie_encryption`
275
+ from `false` to `true`, users may lose their sessions if they access the
276
+ server during deployment.
277
+
278
+ We added fallbacks to downgrade the cookie format when necessary during
279
+ deployment, ensuring compatibility on both old and new instances.
280
+
281
+ *Masaki Hara*
282
+
283
+ * `ActionDispatch::Request.remote_ip` has ip address even when all sites are trusted.
284
+
285
+ Before, if all `X-Forwarded-For` sites were trusted, the `remote_ip` would default to `127.0.0.1`.
286
+ Now, the furthest proxy site is used. e.g.: It now gives an ip address when using curl from the load balancer.
287
+
288
+ *Keenan Brock*
289
+
290
+ * Fix possible information leak / session hijacking vulnerability.
291
+
292
+ The `ActionDispatch::Session::MemcacheStore` is still vulnerable given it requires the
293
+ gem dalli to be updated as well.
294
+
295
+ CVE-2019-16782.
296
+
297
+ * Include child session assertion count in ActionDispatch::IntegrationTest.
298
+
299
+ `IntegrationTest#open_session` uses `dup` to create the new session, which
300
+ meant it had its own copy of `@assertions`. This prevented the assertions
301
+ from being correctly counted and reported.
302
+
303
+ Child sessions now have their `attr_accessor` overridden to delegate to the
304
+ root session.
305
+
306
+ Fixes #32142.
307
+
308
+ *Sam Bostock*
233
309
 
234
- * Deprecate `ActionDispatch::TestResponse` response aliases.
310
+ * Add SameSite protection to every written cookie.
235
311
 
236
- `#success?`, `#missing?` & `#error?` are not supported by the actual
237
- `ActionDispatch::Response` object and can produce false-positives. Instead,
238
- use the response helpers provided by `Rack::Response`.
312
+ Enabling `SameSite` cookie protection is an addition to CSRF protection,
313
+ where cookies won't be sent by browsers in cross-site POST requests when set to `:lax`.
239
314
 
240
- *Trevor Wistaff*
315
+ `:strict` disables cookies being sent in cross-site GET or POST requests.
241
316
 
242
- * Protect from forgery by default
317
+ Passing `:none` disables this protection and is the same as previous versions albeit a `; SameSite=None` is appended to the cookie.
243
318
 
244
- Rather than protecting from forgery in the generated `ApplicationController`,
245
- add it to `ActionController::Base` depending on
246
- `config.action_controller.default_protect_from_forgery`. This configuration
247
- defaults to false to support older versions which have removed it from their
248
- `ApplicationController`, but is set to true for Rails 5.2.
319
+ See upgrade instructions in config/initializers/new_framework_defaults_6_1.rb.
249
320
 
250
- *Lisa Ugray*
321
+ More info [here](https://tools.ietf.org/html/draft-west-first-party-cookies-07)
251
322
 
252
- * Fallback `ActionController::Parameters#to_s` to `Hash#to_s`.
323
+ _NB: Technically already possible as Rack supports SameSite protection, this is to ensure it's applied to all cookies_
253
324
 
254
- *Kir Shatrov*
325
+ *Cédric Fabianski*
255
326
 
256
- * `driven_by` now registers poltergeist and capybara-webkit.
327
+ * Bring back the feature that allows loading external route files from the router.
257
328
 
258
- If poltergeist or capybara-webkit are set as drivers is set for System Tests,
259
- `driven_by` will register the driver and set additional options passed via
260
- the `:options` parameter.
329
+ This feature existed back in 2012 but got reverted with the incentive that
330
+ https://github.com/rails/routing_concerns was a better approach. Turned out
331
+ that this wasn't fully the case and loading external route files from the router
332
+ can be helpful for applications with a really large set of routes.
333
+ Without this feature, application needs to implement routes reloading
334
+ themselves and it's not straightforward.
261
335
 
262
- Refer to the respective driver's documentation to see what options can be passed.
336
+ ```ruby
337
+ # config/routes.rb
263
338
 
264
- *Mario Chavez*
339
+ Rails.application.routes.draw do
340
+ draw(:admin)
341
+ end
265
342
 
266
- * AEAD encrypted cookies and sessions with GCM.
343
+ # config/routes/admin.rb
267
344
 
268
- Encrypted cookies now use AES-GCM which couples authentication and
269
- encryption in one faster step and produces shorter ciphertexts. Cookies
270
- encrypted using AES in CBC HMAC mode will be seamlessly upgraded when
271
- this new mode is enabled via the
272
- `action_dispatch.use_authenticated_cookie_encryption` configuration value.
345
+ get :foo, to: 'foo#bar'
346
+ ```
273
347
 
274
- *Michael J Coyne*
348
+ *Yehuda Katz*, *Edouard Chin*
349
+
350
+ * Fix system test driver option initialization for non-headless browsers.
351
+
352
+ *glaszig*
353
+
354
+ * `redirect_to.action_controller` notifications now include the `ActionDispatch::Request` in
355
+ their payloads as `:request`.
356
+
357
+ *Austin Story*
358
+
359
+ * `respond_to#any` no longer returns a response's Content-Type based on the
360
+ request format but based on the block given.
361
+
362
+ Example:
363
+
364
+ ```ruby
365
+ def my_action
366
+ respond_to do |format|
367
+ format.any { render(json: { foo: 'bar' }) }
368
+ end
369
+ end
370
+
371
+ get('my_action.csv')
372
+ ```
373
+
374
+ The previous behaviour was to respond with a `text/csv` Content-Type which
375
+ is inaccurate since a JSON response is being rendered.
376
+
377
+ Now it correctly returns a `application/json` Content-Type.
378
+
379
+ *Edouard Chin*
380
+
381
+ * Replaces (back)slashes in failure screenshot image paths with dashes.
382
+
383
+ If a failed test case contained a slash or a backslash, a screenshot would be created in a
384
+ nested directory, causing issues with `tmp:clear`.
385
+
386
+ *Damir Zekic*
387
+
388
+ * Add `params.member?` to mimic Hash behavior.
389
+
390
+ *Younes Serraj*
391
+
392
+ * `process_action.action_controller` notifications now include the following in their payloads:
393
+
394
+ * `:request` - the `ActionDispatch::Request`
395
+ * `:response` - the `ActionDispatch::Response`
396
+
397
+ *George Claghorn*
398
+
399
+ * Updated `ActionDispatch::Request.remote_ip` setter to clear set the instance
400
+ `remote_ip` to `nil` before setting the header that the value is derived
401
+ from.
402
+
403
+ Fixes #37383.
404
+
405
+ *Norm Provost*
406
+
407
+ * `ActionController::Base.log_at` allows setting a different log level per request.
408
+
409
+ ```ruby
410
+ # Use the debug level if a particular cookie is set.
411
+ class ApplicationController < ActionController::Base
412
+ log_at :debug, if: -> { cookies[:debug] }
413
+ end
414
+ ```
415
+
416
+ *George Claghorn*
417
+
418
+ * Allow system test screen shots to be taken more than once in
419
+ a test by prefixing the file name with an incrementing counter.
420
+
421
+ Add an environment variable `RAILS_SYSTEM_TESTING_SCREENSHOT_HTML` to
422
+ enable saving of HTML during a screenshot in addition to the image.
423
+ This uses the same image name, with the extension replaced with `.html`
424
+
425
+ *Tom Fakes*
426
+
427
+ * Add `Vary: Accept` header when using `Accept` header for response.
428
+
429
+ For some requests like `/users/1`, Rails uses requests' `Accept`
430
+ header to determine what to return. And if we don't add `Vary`
431
+ in the response header, browsers might accidentally cache different
432
+ types of content, which would cause issues: e.g. javascript got displayed
433
+ instead of html content. This PR fixes these issues by adding `Vary: Accept`
434
+ in these types of requests. For more detailed problem description, please read:
435
+
436
+ https://github.com/rails/rails/pull/36213
437
+
438
+ Fixes #25842.
439
+
440
+ *Stan Lo*
441
+
442
+ * Fix IntegrationTest `follow_redirect!` to follow redirection using the same HTTP verb when following
443
+ a 307 redirection.
444
+
445
+ *Edouard Chin*
446
+
447
+ * System tests require Capybara 3.26 or newer.
448
+
449
+ *George Claghorn*
450
+
451
+ * Reduced log noise handling ActionController::RoutingErrors.
452
+
453
+ *Alberto Fernández-Capel*
454
+
455
+ * Add DSL for configuring HTTP Feature Policy.
456
+
457
+ This new DSL provides a way to configure an HTTP Feature Policy at a
458
+ global or per-controller level. Full details of HTTP Feature Policy
459
+ specification and guidelines can be found at MDN:
460
+
461
+ https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
462
+
463
+ Example global policy:
464
+
465
+ ```ruby
466
+ Rails.application.config.feature_policy do |f|
467
+ f.camera :none
468
+ f.gyroscope :none
469
+ f.microphone :none
470
+ f.usb :none
471
+ f.fullscreen :self
472
+ f.payment :self, "https://secure.example.com"
473
+ end
474
+ ```
475
+
476
+ Example controller level policy:
477
+
478
+ ```ruby
479
+ class PagesController < ApplicationController
480
+ feature_policy do |p|
481
+ p.geolocation "https://example.com"
482
+ end
483
+ end
484
+ ```
485
+
486
+ *Jacob Bednarz*
487
+
488
+ * Add the ability to set the CSP nonce only to the specified directives.
489
+
490
+ Fixes #35137.
491
+
492
+ *Yuji Yaginuma*
275
493
 
276
- * Change the cache key format for fragments to make it easier to debug key churn. The new format is:
494
+ * Keep part when scope option has value.
277
495
 
278
- views/template/action.html.erb:7a1156131a6928cb0026877f8b749ac9/projects/123
279
- ^template path ^template tree digest ^class ^id
496
+ When a route was defined within an optional scope, if that route didn't
497
+ take parameters the scope was lost when using path helpers. This commit
498
+ ensures scope is kept both when the route takes parameters or when it
499
+ doesn't.
280
500
 
281
- *DHH*
501
+ Fixes #33219.
282
502
 
283
- * Add support for recyclable cache keys with fragment caching. This uses the new versioned entries in the
284
- `ActiveSupport::Cache` stores and relies on the fact that Active Record has split `#cache_key` and `#cache_version`
285
- to support it.
503
+ *Alberto Almagro*
286
504
 
287
- *DHH*
505
+ * Added `deep_transform_keys` and `deep_transform_keys!` methods to ActionController::Parameters.
288
506
 
289
- * Add `action_controller_api` and `action_controller_base` load hooks to be called in `ActiveSupport.on_load`
507
+ *Gustavo Gutierrez*
290
508
 
291
- `ActionController::Base` and `ActionController::API` have differing implementations. This means that
292
- the one umbrella hook `action_controller` is not able to address certain situations where a method
293
- may not exist in a certain implementation.
509
+ * Calling `ActionController::Parameters#transform_keys`/`!` without a block now returns
510
+ an enumerator for the parameters instead of the underlying hash.
294
511
 
295
- This is fixed by adding two new hooks so you can target `ActionController::Base` vs `ActionController::API`
512
+ *Eugene Kenny*
296
513
 
297
- Fixes #27013.
514
+ * Fix strong parameters blocks all attributes even when only some keys are invalid (non-numerical).
515
+ It should only block invalid key's values instead.
298
516
 
299
- *Julian Nadeau*
517
+ *Stan Lo*
300
518
 
301
519
 
302
- Please check [5-1-stable](https://github.com/rails/rails/blob/5-1-stable/actionpack/CHANGELOG.md) for previous changes.
520
+ Please check [6-0-stable](https://github.com/rails/rails/blob/6-0-stable/actionpack/CHANGELOG.md) for previous changes.