Skip to content

Commit

Permalink
Remove other places we use query string access
Browse files Browse the repository at this point in the history
  • Loading branch information
nateberkopec committed Apr 17, 2023
1 parent a6490d1 commit 77467f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/mini_profiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,15 @@ def call(env)
if defined?(StackProf) && StackProf.respond_to?(:run)
# do not sully our profile with mini profiler timings
current.measure = false
match_data = query_string.match(/flamegraph_sample_rate=([\d\.]+)/)
match_data = action_parameters(env)['flamegraph_sample_rate']

if match_data && !match_data[1].to_f.zero?
sample_rate = match_data[1].to_f
else
sample_rate = config.flamegraph_sample_rate
end

mode_match_data = query_string.match(/flamegraph_mode=([a-zA-Z]+)/)
mode_match_data = action_parameters(env)['flamegraph_mode']

if mode_match_data && [:cpu, :wall, :object, :custom].include?(mode_match_data[1].to_sym)
mode = mode_match_data[1].to_sym
Expand Down Expand Up @@ -428,7 +428,7 @@ def call(env)
if trace_exceptions
body.close if body.respond_to? :close

query_params = Rack::Utils.parse_nested_query(query_string)
query_params = action_parameters(env)
trace_exceptions_filter = query_params['trace_exceptions_filter']
if trace_exceptions_filter
trace_exceptions_regex = Regexp.new(trace_exceptions_filter)
Expand Down Expand Up @@ -495,6 +495,10 @@ def matches_action?(action, env)
env['HTTP_X_RACK_MINI_PROFILER'] == action
end

def action_parameters(env)
query_params = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
end

def inject_profiler(env, status, headers, body)
# mini profiler is meddling with stuff, we can not cache cause we will get incorrect data
# Rack::ETag has already inserted some nonesense in the chain
Expand Down Expand Up @@ -833,7 +837,7 @@ def handle_snapshots_request(env)
MiniProfiler.authorize_request
status = 200
headers = { 'Content-Type' => 'text/html' }
qp = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
qp = action_parameters(env)
if group_name = qp["group_name"]
list = @storage.snapshots_group(group_name)
list.each do |snapshot|
Expand Down

0 comments on commit 77467f3

Please sign in to comment.