Skip to content

Commit

Permalink
Fix uuencoded attachment processing
Browse files Browse the repository at this point in the history
When attachment has different line endings we should be calling the
calculate_hexdigest helper method.
  • Loading branch information
gbp committed Sep 15, 2023
1 parent 73ff2d6 commit a940d52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/mail_handler/backends/mail_backend.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ def calculate_hexdigest(body)
acc += uudecode(attrs[:body], attrs[:url_part_number])
end
attributes ||= uuencoded_attributes.find do |attrs|
attrs[:hexdigest] == hexdigest
calculate_hexdigest(attrs[:body]) == hexdigest
end

attributes
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/mail_handler/backends/mail_backend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@
Hi Cat!
begin 644 cat.txt
#0V%T
(0V%T#0I#870`
`
end
EML
Expand Down Expand Up @@ -509,8 +509,8 @@
end

context 'when body has been uuencoded' do
let(:body) { "Cat" }
it { is_expected.to include(body: "Cat") }
let(:body) { "Cat\nCat" }
it { is_expected.to include(body: "Cat\r\nCat") }
end

context 'when body does not match' do
Expand Down

0 comments on commit a940d52

Please sign in to comment.