diff options
Diffstat (limited to 'perllib')
-rw-r--r-- | perllib/Cobrand.pm | 2 | ||||
-rw-r--r-- | perllib/Cobrands/Barnet/Util.pm | 2 | ||||
-rw-r--r-- | perllib/FixMyStreet/Geocode.pm | 6 | ||||
-rw-r--r-- | perllib/Page.pm | 10 | ||||
-rw-r--r-- | perllib/Problems.pm | 6 |
5 files changed, 15 insertions, 11 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm index 3d604984d..fa2dd9e88 100644 --- a/perllib/Cobrand.pm +++ b/perllib/Cobrand.pm @@ -55,7 +55,7 @@ my %fns = ( 'front_stats' => { default => '\&Problems::front_stats' }, # Given a STRING ($_[1]) representing a location and a QUERY, return a string that # includes any disambiguating information available - 'disambiguate_location' => { default => '$_[1]' }, + 'disambiguate_location' => { default => '"$_[1]&gl=uk"' }, # Parameter is EPOCHTIME 'prettify_epoch' => { default => '0' }, # Parameters are FORM_NAME, QUERY. Return HTML for any extra needed elements for FORM_NAME diff --git a/perllib/Cobrands/Barnet/Util.pm b/perllib/Cobrands/Barnet/Util.pm index 8ce296aaf..e0821e4ba 100644 --- a/perllib/Cobrands/Barnet/Util.pm +++ b/perllib/Cobrands/Barnet/Util.pm @@ -79,7 +79,7 @@ sub council_check { } my $url = 'http://www.fixmystreet.com/'; $url .= 'alert' if $context eq 'alert'; - $url .= '?pc=' . URI::Escape::uri_escape_utf8($q->param('pc')) if $q->param('pc'); + $url .= '?pc=' . URI::Escape::uri_escape($q->param('pc') if $q->param('pc'); my $error_msg = "That location is not covered by Barnet. Please visit <a href=\"$url\">the main FixMyStreet site</a>."; return (0, $error_msg); diff --git a/perllib/FixMyStreet/Geocode.pm b/perllib/FixMyStreet/Geocode.pm index 892077d6e..475b2f9bc 100644 --- a/perllib/FixMyStreet/Geocode.pm +++ b/perllib/FixMyStreet/Geocode.pm @@ -9,6 +9,7 @@ package FixMyStreet::Geocode; use strict; +use Encode; use Error qw(:try); use File::Slurp; use File::Path (); @@ -87,8 +88,9 @@ sub geocoded_string_coordinates { # of the site. sub string { my ($s, $q) = @_; + $s = decode_utf8($s); $s = lc($s); - $s =~ s/[^-&0-9a-z ']/ /g; + $s =~ s/[^-&\w ']/ /g; $s =~ s/\s+/ /g; $s = URI::Escape::uri_escape_utf8($s); $s = Cobrand::disambiguate_location(Page::get_cobrand($q), "q=$s", $q); @@ -102,7 +104,7 @@ sub string { } else { $url .= ',+UK' unless $url =~ /united\++kingdom$/ || $url =~ /uk$/i || mySociety::Config::get('COUNTRY') ne 'GB'; - $url .= '&sensor=false&gl=uk&key=' . mySociety::Config::get('GOOGLE_MAPS_API_KEY'); + $url .= '&sensor=false&key=' . mySociety::Config::get('GOOGLE_MAPS_API_KEY'); $js = LWP::Simple::get($url); File::Path::mkpath($cache_dir); File::Slurp::write_file($cache_file, $js) if $js && $js !~ /"code":6[12]0/; diff --git a/perllib/Page.pm b/perllib/Page.pm index 4281e584b..308d2a5c6 100644 --- a/perllib/Page.pm +++ b/perllib/Page.pm @@ -51,7 +51,7 @@ my $lastmodified; sub do_fastcgi { my ($func, $lm) = @_; - binmode(STDOUT, ":utf8"); + #binmode(STDOUT, ":utf8"); try { my $W = new mySociety::WatchUpdate(); @@ -113,7 +113,7 @@ sub microsite { my $lang; $lang = 'cy' if $host =~ /cy/; $lang = 'en-gb' if $host =~ /^en\./; - Cobrand::set_lang_and_domain(get_cobrand($q), $lang, 1); + Cobrand::set_lang_and_domain(get_cobrand($q), $lang); # , 1); Problems::set_site_restriction($q); Memcached::set_namespace(mySociety::Config::get('BCI_DB_NAME') . ":"); @@ -304,7 +304,7 @@ sub footer { my ($q, %params) = @_; my $pc = $q->param('pc') || ''; - $pc = "?pc=" . ent($pc) if $pc; + $pc = '?pc=' . URI::Escape::uri_escape($pc) if $pc; my $creditline = _('Built by <a href="http://www.mysociety.org/">mySociety</a>, using some <a href="http://github.com/mysociety/fixmystreet">clever</a> <a href="https://secure.mysociety.org/cvstrac/dir?d=mysociety/services/TilMa">code</a>.'); if (mySociety::Config::get('COUNTRY') eq 'NO') { @@ -561,7 +561,7 @@ sub display_problem_meta_line($$) { $problem->{council} =~ s/\|.*//g; my @councils = split /,/, $problem->{council}; my $areas_info = mySociety::MaPit::call('areas', \@councils); - my $council = join(' and ', map { $areas_info->{$_}->{name} } @councils); + my $council = join(' and ', map { encode_utf8($areas_info->{$_}->{name}) } @councils); $out .= '<small class="council_sent_info">'; $out .= $q->br() . sprintf(_('Sent to %s %s later'), $council, prettify_duration($problem->{whensent}, 'minute')); $out .= '</small>'; @@ -684,7 +684,7 @@ sub short_name { return 'Durham+City' if $area->{name} eq 'Durham City Council'; if ($area->{name} =~ /^(Os|Nes|V\xe5ler|Sande|B\xf8|Her\xf8y)$/) { my $parent = $info->{$area->{parent_area}}->{name}; - return "$area->{name},+$parent"; + return URI::Escape::uri_escape_utf8("$area->{name}, $parent"); } my $name = $area->{name}; $name =~ s/ (Borough|City|District|County) Council$//; diff --git a/perllib/Problems.pm b/perllib/Problems.pm index 8c6eeccad..ff222f874 100644 --- a/perllib/Problems.pm +++ b/perllib/Problems.pm @@ -93,12 +93,14 @@ sub recent_photos { my $key = "recent_photos:$site_key:$num:$lat:$lon:$dist"; $probs = Memcached::get($key); unless ($probs) { - $probs = select_all("select id, title + $probs = mySociety::Locale::in_gb_locale { + select_all("select id, title from problem_find_nearby(?, ?, ?) as nearby, problem where nearby.problem_id = problem.id and state in ('confirmed', 'fixed') and photo is not null $site_restriction order by confirmed desc limit $num", $lat, $lon, $dist); + }; Memcached::set($key, $probs, 3600); } } else { @@ -259,7 +261,7 @@ sub problems_matching_criteria { my $areas_info = mySociety::MaPit::call('areas', \@councils); foreach my $problem (@$problems){ if ($problem->{council}) { - my @council_names = map { $areas_info->{$_}->{name}} @{$problem->{council}} ; + my @council_names = map { encode_utf8($areas_info->{$_}->{name}) } @{$problem->{council}} ; $problem->{council} = join(' and ', @council_names); } } |