diff --git a/changelogs/unreleased/55964-fix-email-encoding.yml b/changelogs/unreleased/55964-fix-email-encoding.yml new file mode 100644 index 0000000000000000000000000000000000000000..2195a853702669aaaff4b3c7d86ea4d3c55617c8 --- /dev/null +++ b/changelogs/unreleased/55964-fix-email-encoding.yml @@ -0,0 +1,5 @@ +--- +title: Fix notfication emails having wrong encoding +merge_request: 26931 +author: +type: fixed diff --git a/config/initializers/premailer.rb b/config/initializers/premailer.rb index cb00d3cfe95be3180ecf877358b29ff27f5d7cf8..87f8e67ef1c3363bd6078f97c6e096c6e7bfee23 100644 --- a/config/initializers/premailer.rb +++ b/config/initializers/premailer.rb @@ -4,5 +4,6 @@ preserve_styles: true, remove_comments: true, remove_ids: false, - remove_scripts: false + remove_scripts: false, + output_encoding: 'US-ASCII' ) diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 3c8897ed37c5956cc70d92ef3dcb08c4610c0e88..5fa1369c00ad2fc5c2148bffd2a5b22353901cdc 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -30,6 +30,19 @@ description: 'My awesome description!') end + describe 'with HTML-encoded entities' do + before do + described_class.test_email('test@test.com', 'Subject', 'Some body with —').deliver + end + + subject { ActionMailer::Base.deliveries.last } + + it 'retains 7bit encoding' do + expect(subject.body.ascii_only?).to eq(true) + expect(subject.body.encoding).to eq('7bit') + end + end + context 'for a project' do shared_examples 'an assignee email' do it 'is sent to the assignee as the author' do