Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
obrie committed Mar 20, 2025
commit 7237dc2a3b55a55d76f5595fe7dc56af9af22354
9 changes: 6 additions & 3 deletions lib/secure_headers/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,12 @@ class Railtie < Rails::Railtie
ActiveSupport.on_load(:action_controller) do
include SecureHeaders

unless Rails.application.config.action_dispatch.default_headers.nil?
conflicting_headers.each do |header|
Rails.application.config.action_dispatch.default_headers.delete(header)
default_headers = Rails.application.config.action_dispatch.default_headers
unless default_headers.nil?
default_headers.each_key do |header|
if conflicting_headers.include?(header.downcase)
default_headers.delete(header)
end
end
end
end
Expand Down