diff options
author | Struan Donald <struan@exo.org.uk> | 2019-09-19 10:38:05 +0100 |
---|---|---|
committer | Struan Donald <struan@exo.org.uk> | 2019-09-19 10:38:05 +0100 |
commit | 4f14c62b661af827aefdc354625c2a16ad8acd48 (patch) | |
tree | cb29d8c96b8936e5779c2345950c2c809b7c4e74 | |
parent | d669a7b97ef7ef12e0acae8d2856ea97419a5e4a (diff) |
strip quote from contact group names
When an open311 category has multiple groups it puts them in the groups
element using CSV escaping. This means that group names can sometimes
feature double quotes. If we send these to the front end then putting
them into the optgroup name attribute breaks the HTML as if the group
name is in the database as `"group name"` you end up with
<optgroup name="" group="" name="">
instead of
<optgroup name="group name">
Hence, stripping the double quotes.
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index 554fbc3b7..9a18d0e32 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -771,6 +771,8 @@ sub setup_categories_and_bodies : Private { my %category_groups = (); for my $category (@category_options) { my $group = $category->{group} // $category->get_extra_metadata('group') // ['']; + # multiple groups from open311 can contain " which upsets the html so strip them + $group =~ s/^"|"$//g; # this could be an array ref or a string my @groups = ref $group eq 'ARRAY' ? @$group : ($group); push( @{$category_groups{$_}}, $category ) for @groups; |