Skip to content

Commit

Permalink
Stop slashes breaking CSV report downloads.
Browse files Browse the repository at this point in the history
Removes slashes from category names as:

Forward slash stops a file being created.
Backward slash stops a file being retrieved.

Co-Authored-By: M Somerville <matthew@mysociety.org>
  • Loading branch information
MorayMySoc and dracos committed Nov 26, 2021
1 parent 04b0145 commit 010af6a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- Fix removal of cached opengraph photos.
- Do not email inactive body comment users. #3587
- Look up organizational domain in DMARC checking. #3603
- Stop slash in category name breaking csv download #3642
- Admin improvements:
- Assignees of reports are now visible in admin reports list and report edit pages.
- Enable per-category hint customisation.
Expand Down
2 changes: 1 addition & 1 deletion perllib/FixMyStreet/Reporting.pm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ has filename => ( is => 'rw', isa => Str, lazy => 1, default => sub {
$self->on_updates ? ('updates') : (),
map {
my $value = $where{$_};
(my $nosp = $value || '') =~ s/ /-/g;
(my $nosp = $value || '') =~ s/[ \/\\]/-/g;
(defined $value and length $value) ? ($_, $nosp) : ()
} sort keys %where
});
Expand Down
6 changes: 6 additions & 0 deletions t/app/controller/dashboard.t
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,12 @@ FixMyStreet::override_config {
$mech->content_contains('Report ID');
};

subtest 'export CSV with slash in category name' => sub {
$mech->create_contact_ok(body_id => $body->id, category => "This/That", email => "this\@example.org");
my $token = 'access_token=' . $counciluser->id . '-1234567890abcdefgh';
$mech->get_ok("/dashboard?export=2&$token&category=This/That");
};

subtest 'view status page' => sub {
# Simulate a partly done file
my $f = Path::Tiny->tempfile(SUFFIX => '.csv-part', DIR => path($UPLOAD_DIR, 'dashboard_csv', $counciluser->id));
Expand Down

0 comments on commit 010af6a

Please sign in to comment.