aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Around.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-03-15 16:41:44 +0000
committerMatthew Somerville <matthew@mysociety.org>2016-03-15 17:28:44 +0000
commitd3d0ab6d5a753d1e5c8277db981f03823683ae1f (patch)
treef3fbdd406aedc27715e466c2c78fae747d600694 /perllib/FixMyStreet/App/Controller/Around.pm
parent4eef3c7e5d067fcf76da2970c957bd34d257a013 (diff)
Don't double-decode geocoded addresses.
Perl 5.20 introduced a version of Encode that errors on decoding already decoded content (rather than returning the same string). Whilst this can be taken as a bug in our code (although the decoding exists because some versions of FastCGI silently UTF-8 encode the content), in the changelog for Perl the only reference to this change is the line: "Encode has been upgraded from version 2.49 to 2.60.".
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm6
1 files changed, 4 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 5ccab4047..1e6d9ec9e 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -351,8 +351,10 @@ sub _geocode : Private {
} else {
if ( ref($suggestions) eq 'ARRAY' ) {
foreach (@$suggestions) {
- push @addresses, decode_utf8($_->{address});
- push @locations, { address => decode_utf8($_->{address}), lat => $_->{latitude}, long => $_->{longitude} };
+ my $address = $_->{address};
+ $address = decode_utf8($address) if !utf8::is_utf8($address);
+ push @addresses, $address;
+ push @locations, { address => $address, lat => $_->{latitude}, long => $_->{longitude} };
}
$response = { suggestions => \@addresses, locations => \@locations };
} else {