diff options
-rw-r--r-- | perllib/FixMyStreet/Alert.pm | 2 | ||||
-rwxr-xr-x | web/index.cgi | 12 | ||||
-rwxr-xr-x | web/rss.cgi | 41 |
3 files changed, 25 insertions, 30 deletions
diff --git a/perllib/FixMyStreet/Alert.pm b/perllib/FixMyStreet/Alert.pm index 4a6e63564..6b50e62e6 100644 --- a/perllib/FixMyStreet/Alert.pm +++ b/perllib/FixMyStreet/Alert.pm @@ -90,7 +90,7 @@ sub delete ($) { sub email_alerts ($) { my ($testing_email) = @_; my $url; - my $q = dbh()->prepare("select * from alert_type where ref not like 'local_problems%'"); + my $q = dbh()->prepare("select * from alert_type where ref not like '%local_problems%'"); $q->execute(); my $testing_email_clause = ''; while (my $alert_type = $q->fetchrow_hashref) { diff --git a/web/index.cgi b/web/index.cgi index 9d2fe45af..89fbca17d 100755 --- a/web/index.cgi +++ b/web/index.cgi @@ -939,9 +939,9 @@ sub display_location { my $rss_url; if ($pc_h) { - $rss_url = "/rss/pc/$pc_h"; + $rss_url = URI::Escape::uri_escape("/rss/pc/$pc_h"); } else { - $rss_url = "/rss/l/$short_lat,$short_lon"; + $rss_url = "/rss/l/$short_lat,$short_lon"; } my %vars = ( @@ -954,10 +954,10 @@ sub display_location { map_end => FixMyStreet::Map::display_map_end(1), url_home => Cobrand::url($cobrand, '/', $q), url_rss => Cobrand::url( - $cobrand, - NewURL($q, -retain => 1, -url=> $rss_url, - pc => undef, x => undef, y => undef, lat=> undef, lon => undef ), - $q), + $cobrand, + NewURL($q, -retain => 1, -url=> $rss_url, + pc => undef, x => undef, y => undef, lat=> undef, lon => undef ), + $q), url_email => Cobrand::url($cobrand, NewURL($q, -retain => 1, pc => undef, lat => $short_lat, lon => $short_lon, -url=>'/alert', feed=>"local:$short_lat:$short_lon"), $q), url_skip => $url_skip, email_me => _('Email me new local problems'), diff --git a/web/rss.cgi b/web/rss.cgi index 1c4b003fe..2d6f3a037 100755 --- a/web/rss.cgi +++ b/web/rss.cgi @@ -64,18 +64,6 @@ sub rss_local_problems { my $q = shift; my $pc = $q->param('pc'); - # As a fallback if pc isn't a postcode, let's upper case it. - my $pretty_pc = uc($pc); - my $pretty_pc_spaceless; - if (mySociety::PostcodeUtil::is_valid_postcode($pc)) { - $pretty_pc = mySociety::PostcodeUtil::canonicalise_postcode($pc); - $pretty_pc_spaceless = $pretty_pc; - $pretty_pc_spaceless =~ s/ //g; - } else { - $pretty_pc_spaceless = $pretty_pc; - } - $pretty_pc_spaceless = URI::Escape::uri_escape_utf8($pretty_pc_spaceless); - my $x = $q->param('x'); my $y = $q->param('y'); my $lat = $q->param('lat'); @@ -119,15 +107,22 @@ sub rss_local_problems { } catch Error::Simple with { $error = shift; }; - if ($error) { - return ''; - } else { + if ($error) { + return ''; + } else { ( $lat, $lon ) = map { Utils::truncate_coordinate($_) } ( $lat, $lon ); - $qs = "?pc=$pretty_pc_spaceless"; - $title_params{'POSTCODE'} = encode_utf8($pretty_pc); + my $pretty_pc = $pc; + if (mySociety::PostcodeUtil::is_valid_postcode($pc)) { + $pretty_pc = mySociety::PostcodeUtil::canonicalise_postcode($pc); + } + my $pretty_pc_escaped = URI::Escape::uri_escape_utf8($pretty_pc); + $pretty_pc_escaped =~ s/%20/+/g; + $qs = "?pc=$pretty_pc_escaped"; + + $title_params{'POSTCODE'} = encode_utf8($pretty_pc); } - # pass through rather than redirecting. + # pass through rather than redirecting. } elsif ( $lat || $lon ) { # pass through } else { @@ -138,7 +133,7 @@ sub rss_local_problems { ( $lat, $lon ) = map { Utils::truncate_coordinate($_) } ( $lat, $lon ); if (!$qs) { - $qs = "?lat=$lat;lon=$lon"; + $qs = "?lat=$lat;lon=$lon"; } if ($d) { @@ -152,16 +147,16 @@ sub rss_local_problems { my $xsl = Cobrand::feed_xsl($cobrand); if ($pc) { - $alert_type = 'postcode_local_problems'; + $alert_type = 'postcode_local_problems'; } else { - $alert_type = 'local_problems'; + $alert_type = 'local_problems'; } my @db_params = ($lat, $lon, $d); if ($state ne 'all') { - $alert_type .= '_state'; - push @db_params, $state; + $alert_type .= '_state'; + push @db_params, $state; } return FixMyStreet::Alert::generate_rss($alert_type, $xsl, $qs, \@db_params, \%title_params, $cobrand, $q); |