diff --git a/CHANGELOG b/CHANGELOG index 463b07b635e77a8f90696a660fabad78b3ceada1..0391f5c5e936a6f3c40cdf1c752c8d15e48d088e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -6,6 +6,7 @@ v 8.13.0 (unreleased) v 8.12.2 (unreleased) - Fix Import/Export not recognising correctly the imported services. + - Fix List-Unsubscribe header in emails v 8.12.1 - Fix a memory leak in HTML::Pipeline::SanitizationFilter::WHITELIST diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb index 9799f1dc886a218388a9c96aa2669aab47a16f93..29f1c52777644371cf0ab8338c0a56b57be44d67 100644 --- a/app/mailers/notify.rb +++ b/app/mailers/notify.rb @@ -109,7 +109,7 @@ def mail_thread(model, headers = {}) headers['X-GitLab-Reply-Key'] = reply_key if !@labels_url && @sent_notification && @sent_notification.unsubscribable? - headers['List-Unsubscribe'] = unsubscribe_sent_notification_url(@sent_notification, force: true) + headers['List-Unsubscribe'] = "<#{unsubscribe_sent_notification_url(@sent_notification, force: true)}>" @sent_notification_url = unsubscribe_sent_notification_url(@sent_notification) end diff --git a/spec/features/unsubscribe_links_spec.rb b/spec/features/unsubscribe_links_spec.rb index cc40671787c164572e4d5447f2883dd91602bde5..33b52d1547efe38ae4bdd4547b34a2a8697eee93 100644 --- a/spec/features/unsubscribe_links_spec.rb +++ b/spec/features/unsubscribe_links_spec.rb @@ -11,7 +11,7 @@ let(:mail) { ActionMailer::Base.deliveries.last } let(:body) { Capybara::Node::Simple.new(mail.default_part_body.to_s) } - let(:header_link) { mail.header['List-Unsubscribe'] } + let(:header_link) { mail.header['List-Unsubscribe'].to_s[1..-2] } # Strip angle brackets let(:body_link) { body.find_link('unsubscribe')['href'] } before do diff --git a/spec/mailers/shared/notify.rb b/spec/mailers/shared/notify.rb index 56872da9a8f883c16d82b1fc9cedf69a3b5bc872..5c9851f14c79cb1e716070907ec4e7a77ff5ba11 100644 --- a/spec/mailers/shared/notify.rb +++ b/spec/mailers/shared/notify.rb @@ -169,8 +169,9 @@ end shared_examples 'an unsubscribeable thread' do - it 'has a List-Unsubscribe header' do + it 'has a List-Unsubscribe header in the correct format' do is_expected.to have_header 'List-Unsubscribe', /unsubscribe/ + is_expected.to have_header 'List-Unsubscribe', /^<.+>$/ end it { is_expected.to have_body_text /unsubscribe/ }