aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/instrumentation.rb2
-rw-r--r--actionpack/lib/action_controller/renderer.rb7
-rw-r--r--actionpack/lib/action_dispatch/http/request.rb2
-rw-r--r--actionpack/lib/action_dispatch/middleware/static.rb23
4 files changed, 18 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/metal/instrumentation.rb b/actionpack/lib/action_controller/metal/instrumentation.rb
index 6f7fc0d624..4c28a45c69 100644
--- a/actionpack/lib/action_controller/metal/instrumentation.rb
+++ b/actionpack/lib/action_controller/metal/instrumentation.rb
@@ -27,7 +27,7 @@ module ActionController
path: request.fullpath
}
- ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
+ ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload)
ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
super.tap do
diff --git a/actionpack/lib/action_controller/renderer.rb b/actionpack/lib/action_controller/renderer.rb
index dadf6d3445..b48c7a1afa 100644
--- a/actionpack/lib/action_controller/renderer.rb
+++ b/actionpack/lib/action_controller/renderer.rb
@@ -65,7 +65,7 @@ module ActionController
def initialize(controller, env, defaults)
@controller = controller
@defaults = defaults
- @env = normalize_keys defaults.merge(env)
+ @env = normalize_keys defaults, env
end
# Render templates with any options from ActionController::Base#render_to_string.
@@ -97,8 +97,9 @@ module ActionController
end
private
- def normalize_keys(env)
+ def normalize_keys(defaults, env)
new_env = {}
+ defaults.each_pair { |k, v| new_env[rack_key_for(k)] = rack_value_for(k, v) }
env.each_pair { |k, v| new_env[rack_key_for(k)] = rack_value_for(k, v) }
new_env["rack.url_scheme"] = new_env["HTTPS"] == "on" ? "https" : "http"
new_env
@@ -120,7 +121,7 @@ module ActionController
}
def rack_key_for(key)
- RACK_KEY_TRANSLATION.fetch(key, key.to_s)
+ RACK_KEY_TRANSLATION[key] || key.to_s
end
def rack_value_for(key, value)
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb
index c78cf4ee8c..54dbb536c1 100644
--- a/actionpack/lib/action_dispatch/http/request.rb
+++ b/actionpack/lib/action_dispatch/http/request.rb
@@ -85,7 +85,7 @@ module ActionDispatch
def controller_class_for(name)
if name
controller_param = name.underscore
- const_name = "#{controller_param.camelize}Controller"
+ const_name = controller_param.camelize << "Controller"
ActiveSupport::Dependencies.constantize(const_name)
else
PASS_NOT_FOUND
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb
index 875c7f9ba1..eddcdbaeac 100644
--- a/actionpack/lib/action_dispatch/middleware/static.rb
+++ b/actionpack/lib/action_dispatch/middleware/static.rb
@@ -32,18 +32,13 @@ module ActionDispatch
return false unless ::Rack::Utils.valid_path? path
path = ::Rack::Utils.clean_path_info path
- paths = [path, "#{path}#{ext}", "#{path}/#{@index}#{ext}"]
+ return ::Rack::Utils.escape_path(path).b if file_readable?(path)
- if match = paths.detect { |p|
- path = File.join(@root, p.b)
- begin
- File.file?(path) && File.readable?(path)
- rescue SystemCallError
- false
- end
- }
- return ::Rack::Utils.escape_path(match).b
- end
+ path_with_ext = path + ext
+ return ::Rack::Utils.escape_path(path_with_ext).b if file_readable?(path_with_ext)
+
+ path << "/" << @index << ext
+ return ::Rack::Utils.escape_path(path).b if file_readable?(path)
end
def call(env)
@@ -95,6 +90,12 @@ module ActionDispatch
false
end
end
+
+ def file_readable?(path)
+ file_path = File.join(@root, path.b)
+ File.file?(file_path) && File.readable?(file_path)
+ rescue SystemCallError
+ end
end
# This middleware will attempt to return the contents of a file's body from