Skip to content

Commit

Permalink
remove altering of custom headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalosh committed Sep 23, 2019
1 parent 806d60b commit 714d0c5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions lib/postmark/message_extensions/mail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ def export_headers
[].tap do |headers|
self.header.fields.each do |field|
key, value = field.name, field.value
next if bogus_headers.include? key.downcase
name = key.split(/-/).map { |i| i.capitalize }.join('-')

headers << { "Name" => name, "Value" => value }
next if reserved_headers.include? key.downcase
headers << { "Name" => key, "Value" => value }
end
end
end
Expand All @@ -173,7 +171,7 @@ def export_native_attachments
end
end

def bogus_headers
def reserved_headers
%q[
return-path x-pm-rcpt
from reply-to
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/postmark/message_extensions/mail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
end
end

let(:mail_message_with_bogus_headers) do
let(:mail_message_with_reserved_headers) do
mail_message.header['Return-Path'] = '[email protected]'
mail_message.header['From'] = '[email protected]'
mail_message.header['Sender'] = '[email protected]'
Expand Down Expand Up @@ -237,7 +237,7 @@
end

describe "#export_headers" do
let(:headers) { mail_message_with_bogus_headers.export_headers }
let(:headers) { mail_message_with_reserved_headers.export_headers }
let(:header_names) { headers.map { |h| h['Name'] } }

specify { expect(header_names).to include('Allowed-Header') }
Expand Down

0 comments on commit 714d0c5

Please sign in to comment.