aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/Geocode.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2017-11-15 12:34:01 +0000
committerMatthew Somerville <matthew-github@dracos.co.uk>2017-11-15 12:34:01 +0000
commit314f3be6ecc3ac7d33a6619a56ecfbab2f6ea494 (patch)
tree73ae42b00de6ade2acc6417f8e4779844150d1c5 /perllib/FixMyStreet/Geocode.pm
parentd51c9bcd916a69b3a71d7d7bdb591c2afcfb5503 (diff)
parentc9dd01a66866dbd7ff867608edcd5c82a0b5e1db (diff)
Merge branch '1905-fix-broken-geocoder-results'
Diffstat (limited to 'perllib/FixMyStreet/Geocode.pm')
-rw-r--r--perllib/FixMyStreet/Geocode.pm6
1 files changed, 5 insertions, 1 deletions
diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm
index dd1adfe71..aeac0ab6d 100644
--- a/perllib/FixMyStreet/Geocode.pm
+++ b/perllib/FixMyStreet/Geocode.pm
@@ -79,8 +79,12 @@ sub cache {
$url .= '&' . $args if $args;
$ua->timeout(15);
$js = LWP::Simple::get($url);
- $cache_dir->mkpath;
+ # The returned data is not correctly decoded if the content type is
+ # e.g. application/json. Which all of our geocoders return.
+ # uncoverable branch false
+ $js = decode_utf8($js) if !utf8::is_utf8($js);
if ($js && (!$re || $js !~ $re) && !FixMyStreet->config('STAGING_SITE')) {
+ $cache_dir->mkpath; # uncoverable statement
# uncoverable statement
$cache_file->spew_utf8($js);
}