aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Dashboard.pm
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2014-04-29 16:11:54 +0100
committerDave Arter <davea@mysociety.org>2014-04-29 16:11:54 +0100
commitd75e161c151c4f1e6dced24eae3170e01f9b7ba6 (patch)
tree9e42928c38a1611c08743e8b5cd521445cba09c4 /perllib/FixMyStreet/App/Controller/Dashboard.pm
parent80f9e52bae06bd0ed551ffdf3d54b9b829e843c1 (diff)
Allow '\n' and other binary chars in dashboard CSV
By default, Text::CSV doesn't allow binary characters such as newline, carriage return etc., in cells. This causes issues when exporting data that contains these characters, such as problem reports with more than one line. This commit also explicitly tells Text::CSV to append a newline to each row instead of joining the rows together with this char at the end. Fixes #494.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Dashboard.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Dashboard.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Dashboard.pm b/perllib/FixMyStreet/App/Controller/Dashboard.pm
index b5f65d8c8..25c6e1923 100644
--- a/perllib/FixMyStreet/App/Controller/Dashboard.pm
+++ b/perllib/FixMyStreet/App/Controller/Dashboard.pm
@@ -195,7 +195,7 @@ sub export_as_csv {
(defined $value and length $value) ? ($_, $value) : ()
} sort keys %where };
- my $csv = Text::CSV->new();
+ my $csv = Text::CSV->new({ binary => 1, eol => "\n" });
$csv->combine(
'Report ID',
'Title',
@@ -264,7 +264,7 @@ sub export_as_csv {
}
$c->res->content_type('text/csv; charset=utf-8');
$c->res->header('content-disposition' => "attachment; filename=${filename}.csv");
- $c->res->body( join "\n", @body );
+ $c->res->body( join "", @body );
}
sub updates_search : Private {