diff options
author | Dave Arter <davea@mysociety.org> | 2017-10-05 12:10:33 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2017-10-05 13:01:11 +0100 |
commit | 60d83f331cd50f0f92f394caac6257e12839bf10 (patch) | |
tree | bfbb3cf6fabc46b74259bd003c5362676f72dc32 /perllib/FixMyStreet/App/Controller/Around.pm | |
parent | 70ddda2c5e851c012b2bb98ec74c87490be6dad0 (diff) |
Fix crash if large number given in postcode field.
It was possible to trigger an SQL error by entering a value larger than
that permitted by the `integer` SQL type. This commit instead returns a
404 in that case.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Around.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm index b872084ff..db5361247 100644 --- a/perllib/FixMyStreet/App/Controller/Around.pm +++ b/perllib/FixMyStreet/App/Controller/Around.pm @@ -8,6 +8,7 @@ use FixMyStreet::Map; use Encode; use JSON::MaybeXS; use Utils; +use Try::Tiny; =head1 NAME @@ -366,9 +367,15 @@ sub lookup_by_ref : Private { external_id => $ref ]); - if ( $problems->count == 0) { + my $count = try { + $problems->count; + } catch { + 0; + }; + + if ( $count == 0 ) { $c->detach( '/page_error_404_not_found', [] ); - } elsif ( $problems->count == 1 ) { + } elsif ( $count == 1 ) { $c->res->redirect( $c->uri_for( '/report', $problems->first->id ) ); } else { $c->stash->{ref} = $ref; |