actionpack 8.0.5.2 → 8.1.0.beta1
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 +231 -277
- data/lib/abstract_controller/asset_paths.rb +4 -2
- data/lib/abstract_controller/base.rb +10 -2
- data/lib/abstract_controller/caching.rb +6 -3
- data/lib/abstract_controller/helpers.rb +1 -1
- data/lib/abstract_controller/logger.rb +2 -1
- data/lib/action_controller/base.rb +1 -1
- data/lib/action_controller/caching.rb +1 -2
- data/lib/action_controller/form_builder.rb +1 -1
- data/lib/action_controller/log_subscriber.rb +7 -0
- data/lib/action_controller/metal/allow_browser.rb +1 -1
- data/lib/action_controller/metal/conditional_get.rb +25 -0
- data/lib/action_controller/metal/data_streaming.rb +1 -3
- 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/live.rb +5 -52
- data/lib/action_controller/metal/permissions_policy.rb +9 -0
- data/lib/action_controller/metal/rate_limiting.rb +22 -7
- data/lib/action_controller/metal/redirecting.rb +61 -5
- data/lib/action_controller/metal/renderers.rb +27 -6
- data/lib/action_controller/metal/rendering.rb +9 -10
- 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/strong_parameters.rb +8 -16
- data/lib/action_controller/railtie.rb +2 -11
- data/lib/action_dispatch/http/cache.rb +111 -1
- data/lib/action_dispatch/http/filter_parameters.rb +5 -3
- data/lib/action_dispatch/http/mime_negotiation.rb +1 -11
- data/lib/action_dispatch/http/mime_types.rb +1 -0
- data/lib/action_dispatch/http/param_builder.rb +28 -27
- data/lib/action_dispatch/http/parameters.rb +3 -3
- data/lib/action_dispatch/http/permissions_policy.rb +4 -0
- data/lib/action_dispatch/http/query_parser.rb +12 -10
- data/lib/action_dispatch/http/request.rb +10 -5
- data/lib/action_dispatch/http/response.rb +16 -3
- data/lib/action_dispatch/http/url.rb +99 -3
- data/lib/action_dispatch/journey/gtg/simulator.rb +33 -12
- data/lib/action_dispatch/journey/gtg/transition_table.rb +33 -43
- data/lib/action_dispatch/journey/nodes/node.rb +2 -1
- data/lib/action_dispatch/journey/route.rb +45 -31
- data/lib/action_dispatch/journey/router/utils.rb +8 -14
- data/lib/action_dispatch/journey/router.rb +59 -81
- data/lib/action_dispatch/journey/routes.rb +7 -0
- data/lib/action_dispatch/journey/visitors.rb +55 -23
- data/lib/action_dispatch/journey/visualizer/fsm.js +4 -6
- data/lib/action_dispatch/middleware/cookies.rb +5 -18
- data/lib/action_dispatch/middleware/debug_exceptions.rb +8 -2
- data/lib/action_dispatch/middleware/debug_view.rb +11 -0
- data/lib/action_dispatch/middleware/exception_wrapper.rb +11 -5
- data/lib/action_dispatch/middleware/executor.rb +12 -2
- data/lib/action_dispatch/middleware/public_exceptions.rb +1 -5
- data/lib/action_dispatch/middleware/session/abstract_store.rb +0 -5
- data/lib/action_dispatch/middleware/session/cache_store.rb +16 -22
- data/lib/action_dispatch/middleware/session/cookie_store.rb +3 -0
- data/lib/action_dispatch/middleware/templates/rescues/_copy_button.html.erb +1 -0
- data/lib/action_dispatch/middleware/templates/rescues/_source.html.erb +3 -2
- 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 +1 -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 +1 -0
- 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 +10 -2
- data/lib/action_dispatch/routing/inspector.rb +4 -1
- data/lib/action_dispatch/routing/mapper.rb +323 -173
- data/lib/action_dispatch/routing/route_set.rb +2 -4
- data/lib/action_dispatch/routing/routes_proxy.rb +0 -1
- data/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb +2 -2
- data/lib/action_dispatch/testing/assertions/response.rb +14 -0
- data/lib/action_dispatch/testing/assertions/routing.rb +11 -3
- data/lib/action_dispatch/testing/integration.rb +7 -7
- data/lib/action_dispatch/testing/request_encoder.rb +9 -9
- data/lib/action_pack/gem_version.rb +3 -3
- metadata +12 -11
|
@@ -2,15 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
# :markup: markdown
|
|
4
4
|
|
|
5
|
+
require "cgi/escape"
|
|
6
|
+
require "cgi/util" if RUBY_VERSION < "3.5"
|
|
5
7
|
require "action_dispatch/journey/router/utils"
|
|
6
8
|
require "action_dispatch/journey/routes"
|
|
7
9
|
require "action_dispatch/journey/formatter"
|
|
8
|
-
|
|
9
|
-
before = $-w
|
|
10
|
-
$-w = false
|
|
11
10
|
require "action_dispatch/journey/parser"
|
|
12
|
-
$-w = before
|
|
13
|
-
|
|
14
11
|
require "action_dispatch/journey/route"
|
|
15
12
|
require "action_dispatch/journey/path/pattern"
|
|
16
13
|
|
|
@@ -31,71 +28,78 @@ module ActionDispatch
|
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
def serve(req)
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
script_name = req.script_name
|
|
38
|
-
|
|
39
|
-
unless route.path.anchored
|
|
40
|
-
req.script_name = (script_name.to_s + match.to_s).chomp("/")
|
|
41
|
-
req.path_info = match.post_match
|
|
42
|
-
req.path_info = "/" + req.path_info unless req.path_info.start_with? "/"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
tmp_params = set_params.merge route.defaults
|
|
46
|
-
parameters.each_pair { |key, val|
|
|
47
|
-
tmp_params[key] = val.force_encoding(::Encoding::UTF_8)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
req.path_parameters = tmp_params
|
|
51
|
-
req.route_uri_pattern = route.path.spec.to_s
|
|
31
|
+
recognize(req) do |route, parameters|
|
|
32
|
+
req.path_parameters = parameters
|
|
33
|
+
req.route = route
|
|
52
34
|
|
|
53
35
|
_, headers, _ = response = route.app.serve(req)
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
req.script_name = script_name
|
|
57
|
-
req.path_info = path_info
|
|
58
|
-
req.path_parameters = set_params
|
|
59
|
-
next
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
return response
|
|
37
|
+
return response unless headers[Constants::X_CASCADE] == "pass"
|
|
63
38
|
end
|
|
64
39
|
|
|
65
40
|
[404, { Constants::X_CASCADE => "pass" }, ["Not Found"]]
|
|
66
41
|
end
|
|
67
42
|
|
|
68
|
-
def recognize(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
rails_req.path_info = match.post_match
|
|
73
|
-
rails_req.path_info = "/" + rails_req.path_info unless rails_req.path_info.start_with? "/"
|
|
74
|
-
end
|
|
43
|
+
def recognize(req, &block)
|
|
44
|
+
req_params = req.path_parameters
|
|
45
|
+
path_info = req.path_info
|
|
46
|
+
script_name = req.script_name
|
|
75
47
|
|
|
76
|
-
|
|
77
|
-
yield(route, parameters)
|
|
78
|
-
end
|
|
79
|
-
end
|
|
48
|
+
routes = filter_routes(path_info)
|
|
80
49
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
asts = groups.values.map(&:first)
|
|
85
|
-
tt.visualizer(asts)
|
|
86
|
-
end
|
|
50
|
+
custom_routes.each { |r|
|
|
51
|
+
routes << r if r.path.match?(path_info)
|
|
52
|
+
}
|
|
87
53
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
54
|
+
if req.head?
|
|
55
|
+
routes = match_head_routes(routes, req)
|
|
56
|
+
else
|
|
57
|
+
routes.select! { |r| r.matches?(req) }
|
|
93
58
|
end
|
|
94
59
|
|
|
95
|
-
|
|
96
|
-
routes.
|
|
60
|
+
if routes.size > 1
|
|
61
|
+
routes.sort! do |a, b|
|
|
62
|
+
a.precedence <=> b.precedence
|
|
63
|
+
end
|
|
97
64
|
end
|
|
98
65
|
|
|
66
|
+
routes.each do |r|
|
|
67
|
+
match_data = r.path.match(path_info)
|
|
68
|
+
|
|
69
|
+
path_parameters = req_params.merge r.defaults
|
|
70
|
+
|
|
71
|
+
index = 1
|
|
72
|
+
match_data.names.each do |name|
|
|
73
|
+
if val = match_data[index]
|
|
74
|
+
val = if val.include?("%")
|
|
75
|
+
CGI.unescapeURIComponent(val)
|
|
76
|
+
else
|
|
77
|
+
val
|
|
78
|
+
end
|
|
79
|
+
val.force_encoding(::Encoding::UTF_8)
|
|
80
|
+
path_parameters[name.to_sym] = val
|
|
81
|
+
end
|
|
82
|
+
index += 1
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
if r.path.anchored
|
|
86
|
+
yield(r, path_parameters)
|
|
87
|
+
else
|
|
88
|
+
req.script_name = (script_name.to_s + match_data.to_s).chomp("/")
|
|
89
|
+
req.path_info = match_data.post_match
|
|
90
|
+
req.path_info = "/" + req.path_info unless req.path_info.start_with? "/"
|
|
91
|
+
|
|
92
|
+
yield(r, path_parameters)
|
|
93
|
+
|
|
94
|
+
req.script_name = script_name
|
|
95
|
+
req.path_info = path_info
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
req.path_parameters = req_params
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
private
|
|
99
103
|
def simulator
|
|
100
104
|
routes.simulator
|
|
101
105
|
end
|
|
@@ -105,35 +109,9 @@ module ActionDispatch
|
|
|
105
109
|
end
|
|
106
110
|
|
|
107
111
|
def filter_routes(path)
|
|
108
|
-
return [] unless ast
|
|
109
112
|
simulator.memos(path) { [] }
|
|
110
113
|
end
|
|
111
114
|
|
|
112
|
-
def find_routes(req)
|
|
113
|
-
path_info = req.path_info
|
|
114
|
-
routes = filter_routes(path_info).concat custom_routes.find_all { |r|
|
|
115
|
-
r.path.match?(path_info)
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
if req.head?
|
|
119
|
-
routes = match_head_routes(routes, req)
|
|
120
|
-
else
|
|
121
|
-
routes.select! { |r| r.matches?(req) }
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
routes.sort_by!(&:precedence)
|
|
125
|
-
|
|
126
|
-
routes.each { |r|
|
|
127
|
-
match_data = r.path.match(path_info)
|
|
128
|
-
path_parameters = {}
|
|
129
|
-
match_data.names.each_with_index { |name, i|
|
|
130
|
-
val = match_data[i + 1]
|
|
131
|
-
path_parameters[name.to_sym] = Utils.unescape_uri(val) if val
|
|
132
|
-
}
|
|
133
|
-
yield [match_data, path_parameters, r]
|
|
134
|
-
}
|
|
135
|
-
end
|
|
136
|
-
|
|
137
115
|
def match_head_routes(routes, req)
|
|
138
116
|
head_routes = routes.select { |r| r.requires_matching_verb? && r.matches?(req) }
|
|
139
117
|
return head_routes unless head_routes.empty?
|
|
@@ -72,6 +72,13 @@ module ActionDispatch
|
|
|
72
72
|
route
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
+
def visualizer
|
|
76
|
+
tt = GTG::Builder.new(ast).transition_table
|
|
77
|
+
groups = anchored_routes.map(&:ast).group_by(&:to_s)
|
|
78
|
+
asts = groups.values.map(&:first)
|
|
79
|
+
tt.visualizer(asts)
|
|
80
|
+
end
|
|
81
|
+
|
|
75
82
|
private
|
|
76
83
|
def clear_cache!
|
|
77
84
|
@ast = nil
|
|
@@ -128,8 +128,8 @@ module ActionDispatch
|
|
|
128
128
|
def visit_DOT(n, seed); terminal(n, seed); end
|
|
129
129
|
|
|
130
130
|
instance_methods(false).each do |pim|
|
|
131
|
-
next unless pim
|
|
132
|
-
DISPATCH_CACHE[
|
|
131
|
+
next unless pim.start_with?("visit_")
|
|
132
|
+
DISPATCH_CACHE[pim.name.delete_prefix("visit_").to_sym] = pim
|
|
133
133
|
end
|
|
134
134
|
end
|
|
135
135
|
|
|
@@ -167,32 +167,64 @@ module ActionDispatch
|
|
|
167
167
|
INSTANCE = new
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
-
class String
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
class String # :nodoc:
|
|
171
|
+
def accept(node, seed)
|
|
172
|
+
case node.type
|
|
173
|
+
when :DOT
|
|
174
|
+
seed << node.left
|
|
175
|
+
when :LITERAL
|
|
176
|
+
seed << node.left
|
|
177
|
+
when :SYMBOL
|
|
178
|
+
seed << node.left
|
|
179
|
+
when :SLASH
|
|
180
|
+
seed << node.left
|
|
181
|
+
when :CAT
|
|
182
|
+
accept(node.right, accept(node.left, seed))
|
|
183
|
+
when :STAR
|
|
184
|
+
accept(node.left, seed)
|
|
185
|
+
when :OR
|
|
177
186
|
last_child = node.children.last
|
|
178
|
-
node.children.
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def visit_GROUP(node, seed)
|
|
190
|
-
visit(node.left, seed.dup << "(") << ")"
|
|
187
|
+
node.children.each do |c|
|
|
188
|
+
accept(c, seed)
|
|
189
|
+
seed << "|" unless last_child == c
|
|
190
|
+
end
|
|
191
|
+
seed
|
|
192
|
+
when :GROUP
|
|
193
|
+
accept(node.left, seed << "(") << ")"
|
|
194
|
+
else
|
|
195
|
+
raise "Unknown node type: #{node.type}"
|
|
191
196
|
end
|
|
197
|
+
end
|
|
192
198
|
|
|
193
|
-
|
|
199
|
+
INSTANCE = new
|
|
194
200
|
end
|
|
195
201
|
|
|
202
|
+
# class String < FunctionalVisitor # :nodoc:
|
|
203
|
+
# private
|
|
204
|
+
# def binary(node, seed)
|
|
205
|
+
# visit(node.right, visit(node.left, seed))
|
|
206
|
+
# end
|
|
207
|
+
#
|
|
208
|
+
# def nary(node, seed)
|
|
209
|
+
# last_child = node.children.last
|
|
210
|
+
# node.children.inject(seed) { |s, c|
|
|
211
|
+
# string = visit(c, s)
|
|
212
|
+
# string << "|" unless last_child == c
|
|
213
|
+
# string
|
|
214
|
+
# }
|
|
215
|
+
# end
|
|
216
|
+
#
|
|
217
|
+
# def terminal(node, seed)
|
|
218
|
+
# seed + node.left
|
|
219
|
+
# end
|
|
220
|
+
#
|
|
221
|
+
# def visit_GROUP(node, seed)
|
|
222
|
+
# visit(node.left, seed.dup << "(") << ")"
|
|
223
|
+
# end
|
|
224
|
+
#
|
|
225
|
+
# INSTANCE = new
|
|
226
|
+
# end
|
|
227
|
+
|
|
196
228
|
class Dot < FunctionalVisitor # :nodoc:
|
|
197
229
|
def initialize
|
|
198
230
|
@nodes = []
|
|
@@ -105,12 +105,10 @@ function match(input) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
if(stdparam_states[state] && default_re.test(token)) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
new_states.push([new_state, null]);
|
|
113
|
-
}
|
|
108
|
+
var new_state = stdparam_states[state];
|
|
109
|
+
highlight_edge(state, new_state);
|
|
110
|
+
highlight_state(new_state);
|
|
111
|
+
new_states.push([new_state, null]);
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
|
|
@@ -324,7 +324,6 @@ module ActionDispatch
|
|
|
324
324
|
def initialize(request)
|
|
325
325
|
@set_cookies = {}
|
|
326
326
|
@delete_cookies = {}
|
|
327
|
-
@upgraded_cookies = Set.new
|
|
328
327
|
@request = request
|
|
329
328
|
@cookies = {}
|
|
330
329
|
@committed = false
|
|
@@ -387,7 +386,6 @@ module ActionDispatch
|
|
|
387
386
|
end
|
|
388
387
|
|
|
389
388
|
handle_options(options)
|
|
390
|
-
@upgraded_cookies.delete(name.to_s)
|
|
391
389
|
|
|
392
390
|
if @cookies[name.to_s] != value || options[:expires]
|
|
393
391
|
@cookies[name.to_s] = value
|
|
@@ -428,14 +426,8 @@ module ActionDispatch
|
|
|
428
426
|
@cookies.each_key { |k| delete(k, options) }
|
|
429
427
|
end
|
|
430
428
|
|
|
431
|
-
def upgraded(name)
|
|
432
|
-
@upgraded_cookies << name.to_s
|
|
433
|
-
end
|
|
434
|
-
|
|
435
429
|
def write(response)
|
|
436
430
|
@set_cookies.each do |name, value|
|
|
437
|
-
next if @upgraded_cookies.include?(name) && request.session_options[:skip]
|
|
438
|
-
|
|
439
431
|
if write_cookie?(value)
|
|
440
432
|
response.set_cookie(name, value)
|
|
441
433
|
end
|
|
@@ -541,10 +533,6 @@ module ActionDispatch
|
|
|
541
533
|
@parent_jar[name] = options
|
|
542
534
|
end
|
|
543
535
|
|
|
544
|
-
def upgraded(name)
|
|
545
|
-
@parent_jar.upgraded(name)
|
|
546
|
-
end
|
|
547
|
-
|
|
548
536
|
protected
|
|
549
537
|
def request; @parent_jar.request; end
|
|
550
538
|
|
|
@@ -611,10 +599,7 @@ module ActionDispatch
|
|
|
611
599
|
return
|
|
612
600
|
end
|
|
613
601
|
|
|
614
|
-
if force_reserialize || reserialize?(dumped)
|
|
615
|
-
self[name] = { value: value }
|
|
616
|
-
upgraded(name)
|
|
617
|
-
end
|
|
602
|
+
self[name] = { value: value } if force_reserialize || reserialize?(dumped)
|
|
618
603
|
|
|
619
604
|
value
|
|
620
605
|
end
|
|
@@ -625,8 +610,10 @@ module ActionDispatch
|
|
|
625
610
|
end
|
|
626
611
|
|
|
627
612
|
def check_for_overflow!(name, options)
|
|
628
|
-
|
|
629
|
-
|
|
613
|
+
total_size = name.to_s.bytesize + options[:value].bytesize
|
|
614
|
+
|
|
615
|
+
if total_size > MAX_COOKIE_SIZE
|
|
616
|
+
raise CookieOverflow, "#{name} cookie overflowed with size #{total_size} bytes"
|
|
630
617
|
end
|
|
631
618
|
end
|
|
632
619
|
end
|
|
@@ -65,7 +65,7 @@ module ActionDispatch
|
|
|
65
65
|
content_type = Mime[:text]
|
|
66
66
|
end
|
|
67
67
|
|
|
68
|
-
if request.
|
|
68
|
+
if request.head?
|
|
69
69
|
render(wrapper.status_code, "", content_type)
|
|
70
70
|
elsif api_request?(content_type)
|
|
71
71
|
render_for_api_request(content_type, wrapper)
|
|
@@ -127,6 +127,7 @@ module ActionDispatch
|
|
|
127
127
|
trace_to_show: wrapper.trace_to_show,
|
|
128
128
|
routes_inspector: routes_inspector(wrapper),
|
|
129
129
|
source_extracts: wrapper.source_extracts,
|
|
130
|
+
exception_message_for_copy: compose_exception_message(wrapper).join("\n"),
|
|
130
131
|
)
|
|
131
132
|
end
|
|
132
133
|
|
|
@@ -140,6 +141,11 @@ module ActionDispatch
|
|
|
140
141
|
return unless logger
|
|
141
142
|
return if !log_rescued_responses?(request) && wrapper.rescue_response?
|
|
142
143
|
|
|
144
|
+
message = compose_exception_message(wrapper)
|
|
145
|
+
log_array(logger, message, request)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def compose_exception_message(wrapper)
|
|
143
149
|
trace = wrapper.exception_trace
|
|
144
150
|
|
|
145
151
|
message = []
|
|
@@ -168,7 +174,7 @@ module ActionDispatch
|
|
|
168
174
|
end
|
|
169
175
|
end
|
|
170
176
|
|
|
171
|
-
|
|
177
|
+
message
|
|
172
178
|
end
|
|
173
179
|
|
|
174
180
|
def log_array(logger, lines, request)
|
|
@@ -55,6 +55,17 @@ module ActionDispatch
|
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
+
def editor_url(location, line: nil)
|
|
59
|
+
if editor = ActiveSupport::Editor.current
|
|
60
|
+
line ||= location&.lineno
|
|
61
|
+
absolute_path = location&.absolute_path
|
|
62
|
+
|
|
63
|
+
if absolute_path && line && File.exist?(absolute_path)
|
|
64
|
+
editor.url_for(absolute_path, line)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
58
69
|
def protect_against_forgery?
|
|
59
70
|
false
|
|
60
71
|
end
|
|
@@ -23,6 +23,7 @@ module ActionDispatch
|
|
|
23
23
|
"ActionDispatch::Http::Parameters::ParseError" => :bad_request,
|
|
24
24
|
"ActionController::BadRequest" => :bad_request,
|
|
25
25
|
"ActionController::ParameterMissing" => :bad_request,
|
|
26
|
+
"ActionController::TooManyRequests" => :too_many_requests,
|
|
26
27
|
"Rack::QueryParser::ParameterTypeError" => :bad_request,
|
|
27
28
|
"Rack::QueryParser::InvalidParameterError" => :bad_request
|
|
28
29
|
)
|
|
@@ -148,15 +149,20 @@ module ActionDispatch
|
|
|
148
149
|
application_trace_with_ids = []
|
|
149
150
|
framework_trace_with_ids = []
|
|
150
151
|
full_trace_with_ids = []
|
|
152
|
+
application_traces = application_trace.map(&:to_s)
|
|
151
153
|
|
|
154
|
+
full_trace = backtrace_cleaner&.clean_locations(backtrace, :all).presence || backtrace
|
|
152
155
|
full_trace.each_with_index do |trace, idx|
|
|
156
|
+
filtered_trace = backtrace_cleaner&.clean_frame(trace, :all) || trace
|
|
157
|
+
|
|
153
158
|
trace_with_id = {
|
|
154
159
|
exception_object_id: @exception.object_id,
|
|
155
160
|
id: idx,
|
|
156
|
-
trace: trace
|
|
161
|
+
trace: trace,
|
|
162
|
+
filtered_trace: filtered_trace,
|
|
157
163
|
}
|
|
158
164
|
|
|
159
|
-
if
|
|
165
|
+
if application_traces.include?(filtered_trace.to_s)
|
|
160
166
|
application_trace_with_ids << trace_with_id
|
|
161
167
|
else
|
|
162
168
|
framework_trace_with_ids << trace_with_id
|
|
@@ -197,7 +203,7 @@ module ActionDispatch
|
|
|
197
203
|
|
|
198
204
|
def source_extracts
|
|
199
205
|
backtrace.map do |trace|
|
|
200
|
-
extract_source(trace)
|
|
206
|
+
extract_source(trace).merge(trace: trace)
|
|
201
207
|
end
|
|
202
208
|
end
|
|
203
209
|
|
|
@@ -261,13 +267,13 @@ module ActionDispatch
|
|
|
261
267
|
end
|
|
262
268
|
|
|
263
269
|
(@exception.backtrace_locations || []).map do |loc|
|
|
264
|
-
if built_methods.key?(loc.
|
|
270
|
+
if built_methods.key?(loc.base_label)
|
|
265
271
|
thread_backtrace_location = if loc.respond_to?(:__getobj__)
|
|
266
272
|
loc.__getobj__
|
|
267
273
|
else
|
|
268
274
|
loc
|
|
269
275
|
end
|
|
270
|
-
SourceMapLocation.new(thread_backtrace_location, built_methods[loc.
|
|
276
|
+
SourceMapLocation.new(thread_backtrace_location, built_methods[loc.base_label])
|
|
271
277
|
else
|
|
272
278
|
loc
|
|
273
279
|
end
|
|
@@ -12,6 +12,10 @@ module ActionDispatch
|
|
|
12
12
|
|
|
13
13
|
def call(env)
|
|
14
14
|
state = @executor.run!(reset: true)
|
|
15
|
+
if response_finished = env["rack.response_finished"]
|
|
16
|
+
response_finished << proc { state.complete! }
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
begin
|
|
16
20
|
response = @app.call(env)
|
|
17
21
|
|
|
@@ -20,7 +24,11 @@ module ActionDispatch
|
|
|
20
24
|
@executor.error_reporter.report(error, handled: false, source: "application.action_dispatch")
|
|
21
25
|
end
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
unless response_finished
|
|
28
|
+
response << ::Rack::BodyProxy.new(response.pop) { state.complete! }
|
|
29
|
+
end
|
|
30
|
+
returned = true
|
|
31
|
+
response
|
|
24
32
|
rescue Exception => error
|
|
25
33
|
request = ActionDispatch::Request.new env
|
|
26
34
|
backtrace_cleaner = request.get_header("action_dispatch.backtrace_cleaner")
|
|
@@ -28,7 +36,9 @@ module ActionDispatch
|
|
|
28
36
|
@executor.error_reporter.report(wrapper.unwrapped_exception, handled: false, source: "application.action_dispatch")
|
|
29
37
|
raise
|
|
30
38
|
ensure
|
|
31
|
-
|
|
39
|
+
if !returned && !response_finished
|
|
40
|
+
state.complete!
|
|
41
|
+
end
|
|
32
42
|
end
|
|
33
43
|
end
|
|
34
44
|
end
|
|
@@ -25,11 +25,7 @@ module ActionDispatch
|
|
|
25
25
|
def call(env)
|
|
26
26
|
request = ActionDispatch::Request.new(env)
|
|
27
27
|
status = request.path_info[1..-1].to_i
|
|
28
|
-
|
|
29
|
-
content_type = request.formats.first
|
|
30
|
-
rescue ActionDispatch::Http::MimeNegotiation::InvalidType
|
|
31
|
-
content_type = Mime[:text]
|
|
32
|
-
end
|
|
28
|
+
content_type = request.formats.first
|
|
33
29
|
body = { status: status, error: Rack::Utils::HTTP_STATUS_CODES.fetch(status, Rack::Utils::HTTP_STATUS_CODES[500]) }
|
|
34
30
|
|
|
35
31
|
if env["action_dispatch.original_request_method"] == "HEAD"
|
|
@@ -20,13 +20,8 @@ module ActionDispatch
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
module Compatibility
|
|
23
|
-
DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc:
|
|
24
|
-
|
|
25
23
|
def initialize(app, options = {})
|
|
26
24
|
options[:key] ||= "_session_id"
|
|
27
|
-
unless options.key?(:same_site) || self.class::DEFAULT_OPTIONS.key?(:same_site)
|
|
28
|
-
options = options.merge(same_site: DEFAULT_SAME_SITE)
|
|
29
|
-
end
|
|
30
25
|
super
|
|
31
26
|
end
|
|
32
27
|
|
|
@@ -18,31 +18,31 @@ module ActionDispatch
|
|
|
18
18
|
# * `expire_after` - The length of time a session will be stored before
|
|
19
19
|
# automatically expiring. By default, the `:expires_in` option of the cache
|
|
20
20
|
# is used.
|
|
21
|
+
# * `check_collisions` - Check if newly generated session ids aren't already in use.
|
|
22
|
+
# If for some reason 128 bits of randomness aren't considered secure enough to avoid
|
|
23
|
+
# collisions, this option can be enabled to ensure newly generated ids aren't in use.
|
|
24
|
+
# By default, it is set to `false` to avoid additional cache write operations.
|
|
21
25
|
#
|
|
22
26
|
class CacheStore < AbstractSecureStore
|
|
23
|
-
LOADED_SESSION_ID = "action_dispatch.session.cache_store.loaded_session_id" # :nodoc:
|
|
24
|
-
|
|
25
27
|
def initialize(app, options = {})
|
|
26
28
|
@cache = options[:cache] || Rails.cache
|
|
27
29
|
options[:expire_after] ||= @cache.options[:expires_in]
|
|
30
|
+
@check_collisions = options[:check_collisions] || false
|
|
28
31
|
super
|
|
29
32
|
end
|
|
30
33
|
|
|
31
34
|
# Get a session from the cache.
|
|
32
|
-
def find_session(
|
|
33
|
-
|
|
34
|
-
req.set_header(LOADED_SESSION_ID, sid.private_id)
|
|
35
|
-
else
|
|
35
|
+
def find_session(env, sid)
|
|
36
|
+
unless sid && (session = get_session_with_fallback(sid))
|
|
36
37
|
sid, session = generate_sid, {}
|
|
37
38
|
end
|
|
38
39
|
[sid, session]
|
|
39
40
|
end
|
|
40
41
|
|
|
41
42
|
# Set a session in the cache.
|
|
42
|
-
def write_session(
|
|
43
|
+
def write_session(env, sid, session, options)
|
|
43
44
|
key = cache_key(sid.private_id)
|
|
44
45
|
if session
|
|
45
|
-
return false if destroyed_since_loaded?(req, sid)
|
|
46
46
|
@cache.write(key, session, expires_in: options[:expire_after])
|
|
47
47
|
else
|
|
48
48
|
@cache.delete(key)
|
|
@@ -67,21 +67,15 @@ module ActionDispatch
|
|
|
67
67
|
@cache.read(cache_key(sid.private_id)) || @cache.read(cache_key(sid.public_id))
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# The request-local cache still holds the entry this request loaded, so
|
|
79
|
-
# a lookup through it cannot see a delete made by another request.
|
|
80
|
-
def exist_in_backend?(key)
|
|
81
|
-
if @cache.respond_to?(:with_local_cache)
|
|
82
|
-
@cache.with_local_cache { @cache.exist?(key) }
|
|
70
|
+
def generate_sid
|
|
71
|
+
if @check_collisions
|
|
72
|
+
loop do
|
|
73
|
+
sid = super
|
|
74
|
+
key = cache_key(sid.private_id)
|
|
75
|
+
break sid if @cache.write(key, {}, unless_exist: true, expires_in: default_options[:expire_after])
|
|
76
|
+
end
|
|
83
77
|
else
|
|
84
|
-
|
|
78
|
+
super
|
|
85
79
|
end
|
|
86
80
|
end
|
|
87
81
|
end
|
|
@@ -59,8 +59,11 @@ module ActionDispatch
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
DEFAULT_SAME_SITE = proc { |request| request.cookies_same_site_protection } # :nodoc:
|
|
63
|
+
|
|
62
64
|
def initialize(app, options = {})
|
|
63
65
|
options[:cookie_only] = true
|
|
66
|
+
options[:same_site] = DEFAULT_SAME_SITE if !options.key?(:same_site)
|
|
64
67
|
super
|
|
65
68
|
end
|
|
66
69
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<button onclick="copyAsText.bind(this)()">Copy as text</button>
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
<tr>
|
|
12
12
|
<td>
|
|
13
13
|
<pre class="line_numbers">
|
|
14
|
-
<% source_extract[:code].each_key do |
|
|
15
|
-
|
|
14
|
+
<% source_extract[:code].each_key do |line| %>
|
|
15
|
+
<% file_url = editor_url(source_extract[:trace], line: line) %>
|
|
16
|
+
<span><%= link_to_if file_url, line, file_url -%></span>
|
|
16
17
|
<% end %>
|
|
17
18
|
</pre>
|
|
18
19
|
</td>
|
|
@@ -13,13 +13,17 @@
|
|
|
13
13
|
<% end %>
|
|
14
14
|
|
|
15
15
|
<% traces.each do |name, trace| %>
|
|
16
|
-
<div id="<%= "#{name.gsub(/\s/, '-')}-#{error_index}" %>" style="display: <%= (name == trace_to_show) ? 'block' : 'none' %>;">
|
|
16
|
+
<div id="<%= "#{name.gsub(/\s/, '-')}-#{error_index}" %>" class="trace-container" style="display: <%= (name == trace_to_show) ? 'block' : 'none' %>;">
|
|
17
17
|
<code class="traces">
|
|
18
18
|
<% trace.each do |frame| %>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
<div class="trace">
|
|
20
|
+
<% file_url = editor_url(frame[:trace]) %>
|
|
21
|
+
<%= file_url && link_to("✏️", file_url, class: "edit-icon") %>
|
|
22
|
+
<a class="trace-frames trace-frames-<%= error_index %>" data-exception-object-id="<%= frame[:exception_object_id] %>" data-frame-id="<%= frame[:id] %>" href="#">
|
|
23
|
+
<%= frame[:trace] %>
|
|
24
|
+
</a>
|
|
25
|
+
<br>
|
|
26
|
+
</div>
|
|
23
27
|
<% end %>
|
|
24
28
|
</code>
|
|
25
29
|
</div>
|