From c05aaa5f353d43deae1f9dae7f9b8eb349c8d1d0 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 20 Feb 2024 18:29:41 +0100 Subject: [PATCH] fix(email): dynamic subject should be escaped, cf RFC 2047 which have its own encoding --- app/models/concerns/mail_template_concern.rb | 2 +- spec/mailers/notification_mailer_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/mail_template_concern.rb b/app/models/concerns/mail_template_concern.rb index 9c957e906..4310a5ce4 100644 --- a/app/models/concerns/mail_template_concern.rb +++ b/app/models/concerns/mail_template_concern.rb @@ -10,7 +10,7 @@ module MailTemplateConcern end def subject_for_dossier(dossier) - replace_tags(subject, dossier).presence || replace_tags(self.class::DEFAULT_SUBJECT, dossier) + replace_tags(subject, dossier, escape: false).presence || replace_tags(self.class::DEFAULT_SUBJECT, dossier, escape: false) end def body_for_dossier(dossier) diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index aa54681e7..3ab227b22 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -140,9 +140,9 @@ RSpec.describe NotificationMailer, type: :mailer do subject(:mail) { described_class.send_en_instruction_notification(dossier) } - context "subject has a special character" do + context "subject has a special character should not be escaped" do let(:subject) { '--libellé démarche--' } - it { expect(mail.subject).to eq("Mon titre avec l'apostrophe") } + it { expect(mail.subject).to eq("Mon titre avec l'apostrophe") } end end end