summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Lee Yu <heinrich@gitlab.com>2019-04-03 20:49:06 +0800
committerHeinrich Lee Yu <heinrich@gitlab.com>2019-04-04 14:38:06 +0800
commitdcaafca516418a7df21bdb27c98e4f3ad461c7fc (patch)
tree81b33a8d1acd2011fc116287ee3599987eba0c21
parentbc696947fdf0423595cbbcf83b6dc94fb2d2290c (diff)
downloadgitlab-ce-55964-fix-email-encoding.tar.gz
Prevent premailer from converting HTML entities55964-fix-email-encoding
This prevents `&mdash` in our templates being change to `-`
-rw-r--r--config/initializers/premailer.rb3
-rw-r--r--spec/mailers/notify_spec.rb13
2 files changed, 15 insertions, 1 deletions
diff --git a/config/initializers/premailer.rb b/config/initializers/premailer.rb
index cb00d3cfe95..87f8e67ef1c 100644
--- a/config/initializers/premailer.rb
+++ b/config/initializers/premailer.rb
@@ -4,5 +4,6 @@ Premailer::Rails.config.merge!(
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 3c8897ed37c..5fa1369c00a 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -30,6 +30,19 @@ describe Notify do
description: 'My awesome description!')
end
+ describe 'with HTML-encoded entities' do
+ before do
+ described_class.test_email('test@test.com', 'Subject', 'Some body with &mdash;').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