aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Location.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/Location.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/Location.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Location.pm3
1 files changed, 2 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Location.pm b/perllib/FixMyStreet/App/Controller/Location.pm
index ff90d3d60..6def423ce 100644
--- a/perllib/FixMyStreet/App/Controller/Location.pm
+++ b/perllib/FixMyStreet/App/Controller/Location.pm
@@ -95,7 +95,8 @@ sub determine_location_from_pc : Private {
# $error doubles up to return multiple choices by being an array
if ( ref($error) eq 'ARRAY' ) {
foreach (@$error) {
- my $a = decode_utf8($_->{address});
+ my $a = $_->{address};
+ $a = decode_utf8($a) if !utf8::is_utf8($a);
$a =~ s/, United Kingdom//;
$a =~ s/, UK//;
$_->{address} = $a;