diff options
author | M Somerville <matthew-github@dracos.co.uk> | 2020-10-15 21:57:06 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-10-16 09:00:00 +0100 |
commit | 3227d1b61693022f6cf0efa790449182efb25784 (patch) | |
tree | 13fba3f17c550d6375256b4e691e976a5a0f2f94 | |
parent | 6dffdeb335030fa7f2ccf7ce70713bef9894cfea (diff) |
Fix issue with unicode in extra in alert emails.
-rw-r--r-- | perllib/FixMyStreet/Template.pm | 2 | ||||
-rw-r--r-- | t/app/controller/alert_new.t | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/Template.pm b/perllib/FixMyStreet/Template.pm index bc087de9a..afb977ac9 100644 --- a/perllib/FixMyStreet/Template.pm +++ b/perllib/FixMyStreet/Template.pm @@ -175,6 +175,7 @@ sub email_sanitize_text : Fn('email_sanitize_text') { my $text = $update->{item_text}; my $extra = $update->{item_extra}; + utf8::encode($extra) if $extra; $extra = $extra ? RABX::wire_rd(new IO::String($extra)) : {}; my $staff = $extra->{is_superuser} || $extra->{is_body_user}; @@ -234,6 +235,7 @@ sub email_sanitize_html : Fn('email_sanitize_html') { my $text = $update->{item_text}; my $extra = $update->{item_extra}; + utf8::encode($extra) if $extra; $extra = $extra ? RABX::wire_rd(new IO::String($extra)) : {}; my $staff = $extra->{is_superuser} || $extra->{is_body_user}; diff --git a/t/app/controller/alert_new.t b/t/app/controller/alert_new.t index 31d8c52ed..562b173c8 100644 --- a/t/app/controller/alert_new.t +++ b/t/app/controller/alert_new.t @@ -1,3 +1,4 @@ +use utf8; use FixMyStreet::TestMech; use FixMyStreet::Script::Alerts; @@ -880,6 +881,7 @@ subtest 'check staff updates can include sanitized HTML' => sub { my $update1 = $mech->create_comment_for_problem($report, $user2, 'Staff User', '<p>This is some update text with <strong>HTML</strong> and *italics*.</p> <ul><li>Even a list</li><li>Which might work</li><li>In the <a href="https://www.fixmystreet.com/">text</a> part</li></ul> <script>not allowed</script>', 't', 'confirmed', undef, { confirmed => $r_dt->clone->add( minutes => 8 ) }); $update1->set_extra_metadata(is_body_user => $user2->from_body->id); + $update1->set_extra_metadata(something_unicodey => "The cafɇ is here"); $update1->update; $mech->create_comment_for_problem($report, $user3, 'Updater User', 'Public users <i>cannot</i> use HTML. <script>not allowed</script>', 't', 'confirmed', undef, { confirmed => $r_dt->clone->add( minutes => 9 ) }); |