Skip to content

Commit

Permalink
Filter out non string header values
Browse files Browse the repository at this point in the history
  • Loading branch information
zuchmanski committed Aug 12, 2024
1 parent 6d1ccac commit 423339b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/castle/headers/filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def call
.keys
.each_with_object({}) do |header_name, acc|
next unless header_name.match(VALUABLE_HEADERS)
next unless @request_env[header_name].is_a?(String)

formatted_name = @header_format.call(header_name)
acc[formatted_name] = @request_env[header_name]
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/castle/headers/filter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
'HTTP_USER_AGENT' => 'Mozilla 1234',
'TEST' => '1',
'REMOTE_ADDR' => '1.2.3.4',
'HTTP_CONTENT_LENGTH' => '0'
'HTTP_CONTENT_LENGTH' => '0',
'http_accept_language.parser' => -> { 'noop' }
)
result[:HTTP_OK] = 'OK'
result
Expand Down

0 comments on commit 423339b

Please sign in to comment.