diff options
author | M Somerville <matthew-github@dracos.co.uk> | 2020-10-02 14:14:17 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-10-02 14:16:48 +0100 |
commit | bf90bf71fbac2c8e1be96646715182f876eccd57 (patch) | |
tree | 1fbf4e2eb8e79745cf84d28d4c5db587baa209e8 | |
parent | f4df25a3067a880d753b81df3eb4d3d843dc0ba0 (diff) |
Don’t strip all spaces from Open311 categories.
If a category’s send method is Open311, only strip spaces from the
ends of the code. We are aware of active Open311 servers that have
codes with spaces in the middle.
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin/Bodies.pm | 6 | ||||
-rw-r--r-- | t/app/controller/admin/bodies.t | 3 |
3 files changed, 8 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8aa628795..a9f118021 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - Fix a few obscure asset layer changing issues. - Fix multiple disable messages for dropdown answers - Do not trigger duplicate check when checking stoppers + - Do not strip spaces from middle of Open311 category codes. #3167 - Admin improvements: - Display user name/email for contributed as reports. #2990 - Interface for enabling anonymous reports for certain categories. #2989 diff --git a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm index f88ad0051..670336c14 100644 --- a/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm +++ b/perllib/FixMyStreet/App/Controller/Admin/Bodies.pm @@ -252,8 +252,12 @@ sub update_contact : Private { } my $email = $c->get_param('email'); - $email =~ s/\s+//g; my $send_method = $c->get_param('send_method') || $contact->body->send_method || ""; + if ($send_method eq 'Open311') { + $email =~ s/^\s+|\s+$//g; + } else { + $email =~ s/\s+//g; + } my $email_unchanged = $contact->email && $email && $contact->email eq $email; my $cobrand = $contact->body->get_cobrand_handler; my $cobrand_valid = $cobrand && $cobrand->call_hook(validate_contact_email => $email); diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t index 75db6f87c..b63cacd9d 100644 --- a/t/app/controller/admin/bodies.t +++ b/t/app/controller/admin/bodies.t @@ -231,9 +231,10 @@ subtest 'check open311 devolved editing' => sub { $mech->content_contains("name=\"category\"\n size=\"30\" value=\"test category\"\n required>", 'Can edit as now devolved'); $mech->submit_form_ok( { with_fields => { send_method => '', - email => 'open311-code', + email => 'open311 code', note => 'Removing email send method', } } ); + $mech->content_contains('open311 code'); $mech->content_contains('Values updated'); }; |