From d75e161c151c4f1e6dced24eae3170e01f9b7ba6 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Tue, 29 Apr 2014 16:11:54 +0100 Subject: 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. --- perllib/FixMyStreet/App/Controller/Dashboard.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'perllib/FixMyStreet/App/Controller/Dashboard.pm') 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 { -- cgit v1.2.3