aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/User.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-06-21 10:29:02 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-06-21 17:27:25 +0100
commit63f8ca8d3fe1e3b52e079e41b29c85d14376f261 (patch)
tree8449714aadfaf13c3a2ee0b14a86c710319f4f92 /perllib/FixMyStreet/DB/Result/User.pm
parente1853898c154356bf0af7ef021f9b1c519e8340b (diff)
Use CSV escaping for categories in URLs.
Categories could contain commas, so splitting on comma is not good enough. Let’s escape the fields as if it’s a line in CSV. Fixes #2166.
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/User.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm12
1 files changed, 12 insertions, 0 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 8b539f85d..5ba597f74 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -131,6 +131,7 @@ __PACKAGE__->load_components("+FixMyStreet::DB::RABXColumn");
__PACKAGE__->rabx_column('extra');
use Moo;
+use Text::CSV;
use FixMyStreet::SMS;
use mySociety::EmailUtil;
use namespace::clean -except => [ 'meta' ];
@@ -544,6 +545,17 @@ has categories => (
},
);
+has categories_string => (
+ is => 'ro',
+ lazy => 1,
+ default => sub {
+ my $self = shift;
+ my $csv = Text::CSV->new;
+ $csv->combine(@{$self->categories});
+ return $csv->string;
+ },
+);
+
sub set_last_active {
my $self = shift;
my $time = shift;