diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-11-27 20:15:33 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-12-09 09:38:03 +0000 |
commit | 2e9e82dfb57b972d1351ecef86687a0d067598b1 (patch) | |
tree | 189119d0c2be5b0327855609d27cb745a3d14d7b /t/app | |
parent | 6c2d3d5a7d84521d34daa2cf7e4be76a54b3b0e0 (diff) |
Switch to default-escaped in email templates.
We add a way to process a template with no auto-escaping, that can be
used for the text parts of emails, and mark various HTML output as safe.
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/helpers/send_email.t | 10 | ||||
-rw-r--r-- | t/app/helpers/send_email_sample.txt | 2 | ||||
-rw-r--r-- | t/app/helpers/send_email_sample_mime.txt | 2 |
3 files changed, 11 insertions, 3 deletions
diff --git a/t/app/helpers/send_email.t b/t/app/helpers/send_email.t index 58b9acaaa..522ee39d0 100644 --- a/t/app/helpers/send_email.t +++ b/t/app/helpers/send_email.t @@ -17,7 +17,7 @@ my $mech = FixMyStreet::TestMech->new; my $c = ctx_request("/"); # set some values in the stash -$c->stash->{foo} = 'bar'; +$c->stash->{foo} = 'bar <b>bold</b>'; # clear the email queue $mech->clear_emails_ok; @@ -118,6 +118,14 @@ subtest 'Inline emails!' => sub { \ {10}\+\ text/plain.*\n \ {10}\+\ text/html.*\n \ {5}\+\ image/gif]x; + $email->walk_parts(sub { + my ($part) = @_; + if ($part->content_type =~ m[text/plain]i) { + like $part->body_str, qr/foo: bar <b>bold<\/b>/; + } elsif ($part->content_type =~ m[text/html]i) { + like $part->body_str, qr/foo: bar <b>bold<\/b>/; + } + }); $mech->clear_emails_ok; }; diff --git a/t/app/helpers/send_email_sample.txt b/t/app/helpers/send_email_sample.txt index 68fe61f0e..e14c536be 100644 --- a/t/app/helpers/send_email_sample.txt +++ b/t/app/helpers/send_email_sample.txt @@ -7,7 +7,7 @@ From: CONTACT_EMAIL Hello, -This is a test email where foo: bar. +This is a test email where foo: bar <b>bold</b>. utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC= =9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81 diff --git a/t/app/helpers/send_email_sample_mime.txt b/t/app/helpers/send_email_sample_mime.txt index 7b4ce91f6..623874149 100644 --- a/t/app/helpers/send_email_sample_mime.txt +++ b/t/app/helpers/send_email_sample_mime.txt @@ -12,7 +12,7 @@ Content-Transfer-Encoding: quoted-printable Hello,
-This is a test email where foo: bar.
+This is a test email where foo: bar <b>bold</b>.
utf8: =E6=88=91=E4=BB=AC=E5=BA=94=E8=AF=A5=E8=83=BD=E5=A4=9F=E6=97=A0=E7=BC=
=9D=E5=A4=84=E7=90=86UTF8=E7=BC=96=E7=A0=81
|