actionpack 7.2.3.1 → 8.1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +606 -120
- data/lib/abstract_controller/asset_paths.rb +4 -2
- data/lib/abstract_controller/base.rb +11 -5
- data/lib/abstract_controller/caching.rb +6 -3
- data/lib/abstract_controller/callbacks.rb +6 -0
- data/lib/abstract_controller/logger.rb +2 -1
- data/lib/abstract_controller/rendering.rb +0 -1
- data/lib/action_controller/api.rb +1 -0
- data/lib/action_controller/base.rb +3 -2
- data/lib/action_controller/caching.rb +1 -2
- data/lib/action_controller/form_builder.rb +4 -4
- data/lib/action_controller/log_subscriber.rb +22 -3
- data/lib/action_controller/metal/allow_browser.rb +12 -2
- data/lib/action_controller/metal/conditional_get.rb +30 -1
- data/lib/action_controller/metal/data_streaming.rb +5 -5
- data/lib/action_controller/metal/exceptions.rb +5 -0
- data/lib/action_controller/metal/flash.rb +1 -4
- data/lib/action_controller/metal/head.rb +3 -1
- data/lib/action_controller/metal/http_authentication.rb +1 -1
- data/lib/action_controller/metal/instrumentation.rb +1 -2
- data/lib/action_controller/metal/live.rb +83 -31
- data/lib/action_controller/metal/permissions_policy.rb +9 -0
- data/lib/action_controller/metal/rate_limiting.rb +39 -9
- data/lib/action_controller/metal/redirecting.rb +107 -14
- data/lib/action_controller/metal/renderers.rb +29 -9
- data/lib/action_controller/metal/rendering.rb +16 -3
- data/lib/action_controller/metal/request_forgery_protection.rb +18 -10
- data/lib/action_controller/metal/rescue.rb +9 -0
- data/lib/action_controller/metal/streaming.rb +5 -84
- data/lib/action_controller/metal/strong_parameters.rb +294 -98
- data/lib/action_controller/railtie.rb +35 -15
- data/lib/action_controller/structured_event_subscriber.rb +116 -0
- data/lib/action_controller/test_case.rb +12 -2
- data/lib/action_dispatch/http/cache.rb +143 -12
- data/lib/action_dispatch/http/content_security_policy.rb +14 -1
- data/lib/action_dispatch/http/filter_parameters.rb +5 -3
- data/lib/action_dispatch/http/mime_negotiation.rb +66 -2
- data/lib/action_dispatch/http/mime_types.rb +1 -0
- data/lib/action_dispatch/http/param_builder.rb +187 -0
- data/lib/action_dispatch/http/param_error.rb +26 -0
- data/lib/action_dispatch/http/parameters.rb +3 -3
- data/lib/action_dispatch/http/permissions_policy.rb +8 -1
- data/lib/action_dispatch/http/query_parser.rb +55 -0
- data/lib/action_dispatch/http/request.rb +70 -21
- data/lib/action_dispatch/http/response.rb +52 -17
- data/lib/action_dispatch/http/url.rb +112 -16
- data/lib/action_dispatch/journey/formatter.rb +5 -0
- data/lib/action_dispatch/journey/gtg/simulator.rb +33 -12
- data/lib/action_dispatch/journey/gtg/transition_table.rb +33 -41
- data/lib/action_dispatch/journey/nodes/node.rb +2 -1
- data/lib/action_dispatch/journey/parser.rb +99 -196
- data/lib/action_dispatch/journey/route.rb +45 -31
- data/lib/action_dispatch/journey/router/utils.rb +9 -15
- data/lib/action_dispatch/journey/router.rb +59 -81
- data/lib/action_dispatch/journey/routes.rb +7 -0
- data/lib/action_dispatch/journey/scanner.rb +44 -42
- data/lib/action_dispatch/journey/visitors.rb +55 -23
- data/lib/action_dispatch/journey/visualizer/fsm.js +4 -6
- data/lib/action_dispatch/log_subscriber.rb +7 -3
- data/lib/action_dispatch/middleware/cookies.rb +24 -5
- data/lib/action_dispatch/middleware/debug_exceptions.rb +24 -5
- data/lib/action_dispatch/middleware/debug_view.rb +11 -5
- data/lib/action_dispatch/middleware/exception_wrapper.rb +12 -12
- data/lib/action_dispatch/middleware/executor.rb +12 -2
- data/lib/action_dispatch/middleware/host_authorization.rb +3 -2
- data/lib/action_dispatch/middleware/public_exceptions.rb +1 -5
- data/lib/action_dispatch/middleware/remote_ip.rb +61 -24
- data/lib/action_dispatch/middleware/request_id.rb +2 -1
- data/lib/action_dispatch/middleware/session/abstract_store.rb +5 -0
- data/lib/action_dispatch/middleware/session/cache_store.rb +44 -4
- data/lib/action_dispatch/middleware/session/cookie_store.rb +0 -3
- data/lib/action_dispatch/middleware/ssl.rb +13 -3
- data/lib/action_dispatch/middleware/templates/rescues/_copy_button.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +3 -5
- data/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb +9 -5
- data/lib/action_dispatch/middleware/templates/rescues/blocked_host.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.html.erb +4 -0
- data/lib/action_dispatch/middleware/templates/rescues/invalid_statement.text.erb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/layout.erb +50 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_exact_template.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/missing_template.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb +7 -8
- data/lib/action_dispatch/middleware/templates/rescues/routing_error.text.erb +1 -1
- data/lib/action_dispatch/middleware/templates/rescues/template_error.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/unknown_action.html.erb +1 -0
- data/lib/action_dispatch/railtie.rb +21 -0
- data/lib/action_dispatch/request/session.rb +1 -0
- data/lib/action_dispatch/request/utils.rb +9 -3
- data/lib/action_dispatch/routing/inspector.rb +80 -57
- data/lib/action_dispatch/routing/mapper.rb +404 -223
- data/lib/action_dispatch/routing/polymorphic_routes.rb +2 -2
- data/lib/action_dispatch/routing/redirection.rb +10 -7
- data/lib/action_dispatch/routing/route_set.rb +21 -12
- data/lib/action_dispatch/routing/routes_proxy.rb +1 -0
- data/lib/action_dispatch/structured_event_subscriber.rb +20 -0
- data/lib/action_dispatch/system_test_case.rb +3 -3
- data/lib/action_dispatch/system_testing/browser.rb +15 -22
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +2 -2
- data/lib/action_dispatch/testing/assertions/response.rb +26 -2
- data/lib/action_dispatch/testing/assertions/routing.rb +27 -15
- data/lib/action_dispatch/testing/integration.rb +18 -7
- data/lib/action_dispatch/testing/test_helpers/page_dump_helper.rb +1 -1
- data/lib/action_dispatch.rb +14 -4
- data/lib/action_pack/gem_version.rb +3 -3
- metadata +18 -48
- data/lib/action_dispatch/journey/parser.y +0 -50
- data/lib/action_dispatch/journey/parser_extras.rb +0 -33
|
@@ -71,32 +71,39 @@ module ActionController # :nodoc:
|
|
|
71
71
|
included do
|
|
72
72
|
# Sets the token parameter name for RequestForgery. Calling
|
|
73
73
|
# `protect_from_forgery` sets it to `:authenticity_token` by default.
|
|
74
|
-
|
|
74
|
+
singleton_class.delegate :request_forgery_protection_token, :request_forgery_protection_token=, to: :config
|
|
75
|
+
delegate :request_forgery_protection_token, :request_forgery_protection_token=, to: :config
|
|
75
76
|
self.request_forgery_protection_token ||= :authenticity_token
|
|
76
77
|
|
|
77
78
|
# Holds the class which implements the request forgery protection.
|
|
78
|
-
|
|
79
|
+
singleton_class.delegate :forgery_protection_strategy, :forgery_protection_strategy=, to: :config
|
|
80
|
+
delegate :forgery_protection_strategy, :forgery_protection_strategy=, to: :config
|
|
79
81
|
self.forgery_protection_strategy = nil
|
|
80
82
|
|
|
81
83
|
# Controls whether request forgery protection is turned on or not. Turned off by
|
|
82
84
|
# default only in test mode.
|
|
83
|
-
|
|
85
|
+
singleton_class.delegate :allow_forgery_protection, :allow_forgery_protection=, to: :config
|
|
86
|
+
delegate :allow_forgery_protection, :allow_forgery_protection=, to: :config
|
|
84
87
|
self.allow_forgery_protection = true if allow_forgery_protection.nil?
|
|
85
88
|
|
|
86
89
|
# Controls whether a CSRF failure logs a warning. On by default.
|
|
87
|
-
|
|
90
|
+
singleton_class.delegate :log_warning_on_csrf_failure, :log_warning_on_csrf_failure=, to: :config
|
|
91
|
+
delegate :log_warning_on_csrf_failure, :log_warning_on_csrf_failure=, to: :config
|
|
88
92
|
self.log_warning_on_csrf_failure = true
|
|
89
93
|
|
|
90
94
|
# Controls whether the Origin header is checked in addition to the CSRF token.
|
|
91
|
-
|
|
95
|
+
singleton_class.delegate :forgery_protection_origin_check, :forgery_protection_origin_check=, to: :config
|
|
96
|
+
delegate :forgery_protection_origin_check, :forgery_protection_origin_check=, to: :config
|
|
92
97
|
self.forgery_protection_origin_check = false
|
|
93
98
|
|
|
94
99
|
# Controls whether form-action/method specific CSRF tokens are used.
|
|
95
|
-
|
|
100
|
+
singleton_class.delegate :per_form_csrf_tokens, :per_form_csrf_tokens=, to: :config
|
|
101
|
+
delegate :per_form_csrf_tokens, :per_form_csrf_tokens=, to: :config
|
|
96
102
|
self.per_form_csrf_tokens = false
|
|
97
103
|
|
|
98
104
|
# The strategy to use for storing and retrieving CSRF tokens.
|
|
99
|
-
|
|
105
|
+
singleton_class.delegate :csrf_token_storage_strategy, :csrf_token_storage_strategy=, to: :config
|
|
106
|
+
delegate :csrf_token_storage_strategy, :csrf_token_storage_strategy=, to: :config
|
|
100
107
|
self.csrf_token_storage_strategy = SessionStore.new
|
|
101
108
|
|
|
102
109
|
helper_method :form_authenticity_token
|
|
@@ -461,7 +468,7 @@ module ActionController # :nodoc:
|
|
|
461
468
|
# * Does the `X-CSRF-Token` header match the form_authenticity_token?
|
|
462
469
|
#
|
|
463
470
|
def verified_request? # :doc:
|
|
464
|
-
|
|
471
|
+
request.get? || request.head? || !protect_against_forgery? ||
|
|
465
472
|
(valid_request_origin? && any_authenticity_token_valid?)
|
|
466
473
|
end
|
|
467
474
|
|
|
@@ -621,6 +628,7 @@ module ActionController # :nodoc:
|
|
|
621
628
|
If you cannot change the referrer policy, you can disable origin checking with the
|
|
622
629
|
Rails.application.config.action_controller.forgery_protection_origin_check setting.
|
|
623
630
|
MSG
|
|
631
|
+
private_constant :NULL_ORIGIN_MESSAGE
|
|
624
632
|
|
|
625
633
|
# Checks if the request originated from the same origin by looking at the Origin
|
|
626
634
|
# header.
|
|
@@ -634,7 +642,7 @@ module ActionController # :nodoc:
|
|
|
634
642
|
end
|
|
635
643
|
end
|
|
636
644
|
|
|
637
|
-
def normalize_action_path(action_path)
|
|
645
|
+
def normalize_action_path(action_path)
|
|
638
646
|
uri = URI.parse(action_path)
|
|
639
647
|
|
|
640
648
|
if uri.relative? && (action_path.blank? || !action_path.start_with?("/"))
|
|
@@ -644,7 +652,7 @@ module ActionController # :nodoc:
|
|
|
644
652
|
end
|
|
645
653
|
end
|
|
646
654
|
|
|
647
|
-
def normalize_relative_action_path(rel_action_path)
|
|
655
|
+
def normalize_relative_action_path(rel_action_path)
|
|
648
656
|
uri = URI.parse(request.path)
|
|
649
657
|
# add the action path to the request.path
|
|
650
658
|
uri.path += "/#{rel_action_path}"
|
|
@@ -13,6 +13,15 @@ module ActionController # :nodoc:
|
|
|
13
13
|
extend ActiveSupport::Concern
|
|
14
14
|
include ActiveSupport::Rescuable
|
|
15
15
|
|
|
16
|
+
module ClassMethods
|
|
17
|
+
def handler_for_rescue(exception, ...) # :nodoc:
|
|
18
|
+
if handler = super
|
|
19
|
+
ActiveSupport::Notifications.instrument("rescue_from_callback.action_controller", exception: exception)
|
|
20
|
+
handler
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
16
25
|
# Override this method if you want to customize when detailed exceptions must be
|
|
17
26
|
# shown. This method is only called when `consider_all_requests_local` is
|
|
18
27
|
# `false`. By default, it returns `false`, but someone may set it to
|
|
@@ -165,95 +165,16 @@ module ActionController # :nodoc:
|
|
|
165
165
|
#
|
|
166
166
|
# ## Web server support
|
|
167
167
|
#
|
|
168
|
-
#
|
|
169
|
-
# instructions for each of them.
|
|
170
|
-
#
|
|
171
|
-
# #### Unicorn
|
|
172
|
-
#
|
|
173
|
-
# Unicorn supports streaming but it needs to be configured. For this, you need
|
|
174
|
-
# to create a config file as follow:
|
|
175
|
-
#
|
|
176
|
-
# # unicorn.config.rb
|
|
177
|
-
# listen 3000, tcp_nopush: false
|
|
178
|
-
#
|
|
179
|
-
# And use it on initialization:
|
|
180
|
-
#
|
|
181
|
-
# unicorn_rails --config-file unicorn.config.rb
|
|
182
|
-
#
|
|
183
|
-
# You may also want to configure other parameters like `:tcp_nodelay`.
|
|
184
|
-
#
|
|
185
|
-
# For more information, please check the
|
|
186
|
-
# [documentation](https://bogomips.org/unicorn/Unicorn/Configurator.html#method-
|
|
187
|
-
# i-listen).
|
|
188
|
-
#
|
|
189
|
-
# If you are using Unicorn with NGINX, you may need to tweak NGINX. Streaming
|
|
190
|
-
# should work out of the box on Rainbows.
|
|
191
|
-
#
|
|
192
|
-
# #### Passenger
|
|
193
|
-
#
|
|
194
|
-
# Phusion Passenger with NGINX, offers two streaming mechanisms out of the box.
|
|
195
|
-
#
|
|
196
|
-
# 1. NGINX response buffering mechanism which is dependent on the value of
|
|
197
|
-
# `passenger_buffer_response` option (default is "off").
|
|
198
|
-
# 2. Passenger buffering system which is always 'on' irrespective of the value
|
|
199
|
-
# of `passenger_buffer_response`.
|
|
200
|
-
#
|
|
201
|
-
#
|
|
202
|
-
# When `passenger_buffer_response` is turned "on", then streaming would be done
|
|
203
|
-
# at the NGINX level which waits until the application is done sending the
|
|
204
|
-
# response back to the client.
|
|
205
|
-
#
|
|
206
|
-
# For more information, please check the [documentation]
|
|
207
|
-
# (https://www.phusionpassenger.com/docs/references/config_reference/nginx/#passenger_buffer_response).
|
|
168
|
+
# Rack 3+ compatible servers all support streaming.
|
|
208
169
|
module Streaming
|
|
209
|
-
class Body # :nodoc:
|
|
210
|
-
TERM = "\r\n"
|
|
211
|
-
TAIL = "0#{TERM}"
|
|
212
|
-
|
|
213
|
-
# Store the response body to be chunked.
|
|
214
|
-
def initialize(body)
|
|
215
|
-
@body = body
|
|
216
|
-
end
|
|
217
|
-
|
|
218
|
-
# For each element yielded by the response body, yield the element in chunked
|
|
219
|
-
# encoding.
|
|
220
|
-
def each(&block)
|
|
221
|
-
term = TERM
|
|
222
|
-
@body.each do |chunk|
|
|
223
|
-
size = chunk.bytesize
|
|
224
|
-
next if size == 0
|
|
225
|
-
|
|
226
|
-
yield [size.to_s(16), term, chunk.b, term].join
|
|
227
|
-
end
|
|
228
|
-
yield TAIL
|
|
229
|
-
yield term
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
# Close the response body if the response body supports it.
|
|
233
|
-
def close
|
|
234
|
-
@body.close if @body.respond_to?(:close)
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
170
|
private
|
|
239
|
-
# Set proper cache control and transfer encoding when streaming
|
|
240
|
-
def _process_options(options)
|
|
241
|
-
super
|
|
242
|
-
if options[:stream]
|
|
243
|
-
if request.version == "HTTP/1.0"
|
|
244
|
-
options.delete(:stream)
|
|
245
|
-
else
|
|
246
|
-
headers["Cache-Control"] ||= "no-cache"
|
|
247
|
-
headers["Transfer-Encoding"] = "chunked"
|
|
248
|
-
headers.delete("Content-Length")
|
|
249
|
-
end
|
|
250
|
-
end
|
|
251
|
-
end
|
|
252
|
-
|
|
253
171
|
# Call render_body if we are streaming instead of usual `render`.
|
|
254
172
|
def _render_template(options)
|
|
255
173
|
if options.delete(:stream)
|
|
256
|
-
|
|
174
|
+
# It shouldn't be necessary to set this.
|
|
175
|
+
headers["cache-control"] ||= "no-cache"
|
|
176
|
+
|
|
177
|
+
view_renderer.render_body(view_context, options)
|
|
257
178
|
else
|
|
258
179
|
super
|
|
259
180
|
end
|