From cc3ef2ab672b1bdf1ed0bc1a921ef355f34b1415 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 8 Jan 2014 18:36:14 +0100 Subject: Work around Cache::File UTF-8 problems --- cgi/index.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cgi/index.pl b/cgi/index.pl index c02fbac..4134e4e 100644 --- a/cgi/index.pl +++ b/cgi/index.pl @@ -20,13 +20,18 @@ sub get_results_for { default_expires => $refresh_interval . ' sec', ); - my $results = $cache->thaw($station); + # Cache::File has UTF-8 problems, so strip it (and any other potentially + # problematic chars). + my $cstation = $station; + $cstation =~ tr{[0-9a-zA-Z -]}{}cd; + + my $results = $cache->thaw($cstation); if ( not $results ) { my $status = Travel::Status::DE::DeutscheBahn->new( station => $station ); $results = [ $status->results ]; - $cache->freeze( $station, $results ); + $cache->freeze( $cstation, $results ); } return @{$results}; -- cgit v1.2.3