Skip to content

Commit a912a94

Browse files
obrierei-moo
authored andcommitted
Remove non-lowercase headers in Rails default configuration (fixes #541)
While this gem now uses lowercase headers, the Rails default configuration still defines non-lowercase headers. As a result, our Railtie will not remove those conflicting headers. This change ensures that we're accounting for both lowercase and non-lowercase default headers in Rails.
1 parent 40674a3 commit a912a94

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/secure_headers/railtie.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ class Railtie < Rails::Railtie
2222
ActiveSupport.on_load(:action_controller) do
2323
include SecureHeaders
2424

25-
unless Rails.application.config.action_dispatch.default_headers.nil?
26-
conflicting_headers.each do |header|
27-
Rails.application.config.action_dispatch.default_headers.delete(header)
25+
default_headers = Rails.application.config.action_dispatch.default_headers
26+
unless default_headers.nil?
27+
default_headers.each_key do |header|
28+
if conflicting_headers.include?(header.downcase)
29+
default_headers.delete(header)
30+
end
2831
end
2932
end
3033
end

0 commit comments

Comments
 (0)