From a940d5242168fa4f5a9013185f5acc56c59aac10 Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Fri, 15 Sep 2023 12:14:52 +0100 Subject: [PATCH] Fix uuencoded attachment processing When attachment has different line endings we should be calling the calculate_hexdigest helper method. --- lib/mail_handler/backends/mail_backend.rb | 2 +- spec/lib/mail_handler/backends/mail_backend_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb index 3bfceca341..87b612b7e5 100644 --- a/lib/mail_handler/backends/mail_backend.rb +++ b/lib/mail_handler/backends/mail_backend.rb @@ -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 diff --git a/spec/lib/mail_handler/backends/mail_backend_spec.rb b/spec/lib/mail_handler/backends/mail_backend_spec.rb index 09fdc6fbd1..c5dda569b6 100644 --- a/spec/lib/mail_handler/backends/mail_backend_spec.rb +++ b/spec/lib/mail_handler/backends/mail_backend_spec.rb @@ -450,7 +450,7 @@ Hi Cat! begin 644 cat.txt - #0V%T + (0V%T#0I#870` ` end EML @@ -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