diff options
-rw-r--r-- | Changelog | 4 | ||||
-rw-r--r-- | lib/Travel/Routing/DE/EFA.pm | 37 | ||||
-rw-r--r-- | t/21-vrr.t | 9 |
3 files changed, 22 insertions, 28 deletions
@@ -1,3 +1,7 @@ +git HEAD + + * Fix encoding issues caused by recent API changes + Travel::Routing::DE::VRR 2.15 - Sat Mar 04 2017 * Remove support for Vorarlberger Verkehrsverbund (VVV) backend diff --git a/lib/Travel/Routing/DE/EFA.pm b/lib/Travel/Routing/DE/EFA.pm index 8f9ac29..06175f6 100644 --- a/lib/Travel/Routing/DE/EFA.pm +++ b/lib/Travel/Routing/DE/EFA.pm @@ -7,7 +7,7 @@ use 5.010; no if $] >= 5.018, warnings => "experimental::smartmatch"; use Carp qw(cluck); -use Encode qw(decode encode); +use Encode qw(encode); use Travel::Routing::DE::EFA::Route; use Travel::Routing::DE::EFA::Route::Message; use LWP::UserAgent; @@ -435,7 +435,7 @@ sub create_post { } for my $val ( values %{ $self->{post} } ) { - $val = encode( 'ISO-8859-15', $val ); + $val = encode( 'UTF-8', $val ); } return; @@ -555,7 +555,6 @@ sub parse_cur_info { raw_content => $e_content->textContent, ); for my $key ( keys %msg ) { - $msg{$key} = decode( 'UTF-8', $msg{$key} ); chomp( $msg{$key} ); } return Travel::Routing::DE::EFA::Route::Message->new(%msg); @@ -565,7 +564,7 @@ sub parse_reg_info { my ( $self, $node ) = @_; my %msg = ( - summary => decode( 'UTF-8', $node->textContent ), + summary => $node->textContent, ); return Travel::Routing::DE::EFA::Route::Message->new(%msg); @@ -686,10 +685,6 @@ sub parse_xml_part { arrival_platform => $e_arr->getAttribute('platformName'), }; - for my $key ( keys %{$hash} ) { - $hash->{$key} = decode( 'UTF-8', $hash->{$key} ); - } - if ($e_fp) { # Note that position=IDEST footpaths are coupled with a special @@ -721,7 +716,7 @@ sub parse_xml_part { next; } - my $name = decode( 'UTF-8', $ve->getAttribute('name') ); + my $name = $ve->getAttribute('name'); my $platform = $ve->getAttribute('platformName'); if ( $name ~~ [ $hash->{departure_stop}, $hash->{arrival_stop} ] ) { @@ -816,25 +811,21 @@ sub check_ambiguous_xml { if ( $s_place eq 'list' ) { Travel::Routing::DE::EFA::Exception::Ambiguous->throw( - post_key => 'place', - post_value => decode( - 'UTF-8', - ( $e_place->findnodes($xp_place_input) )[0]->textContent - ), + post_key => 'place', + post_value => + ( $e_place->findnodes($xp_place_input) )[0]->textContent, possibilities => join( q{ | }, - map { decode( 'UTF-8', $_->textContent ) } + map { $_->textContent } @{ $e_place->findnodes($xp_place_elem) } ) ); } if ( $s_name eq 'list' ) { Travel::Routing::DE::EFA::Exception::Ambiguous->throw( - post_key => 'name', - post_value => decode( - 'UTF-8', ( $e_name->findnodes($xp_name_input) )[0]->textContent - ), + post_key => 'name', + post_value => + ( $e_name->findnodes($xp_name_input) )[0]->textContent, possibilities => join( q{ | }, - map { decode( 'UTF-8', $_->textContent ) } - @{ $e_name->findnodes($xp_name_elem) } ) + map { $_->textContent } @{ $e_name->findnodes($xp_name_elem) } ) ); } @@ -928,8 +919,8 @@ sub get_efa_urls { shortname => 'VRNdelfi', }, { - url => 'http://fahrplanauskunft.vrn.de/vrn/XML_TRIP_REQUEST2', - name => 'Verkehrsverbund Rhein-Neckar', + url => 'http://fahrplanauskunft.vrn.de/vrn/XML_TRIP_REQUEST2', + name => 'Verkehrsverbund Rhein-Neckar', shortname => 'VRN', }, { @@ -5,7 +5,6 @@ use 5.010; use utf8; -use Encode qw(decode); use File::Slurp qw(slurp); use Test::More tests => 82; @@ -56,7 +55,7 @@ is_deeply( [ $c0->departure_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filena is_deeply( [ $c0->departure_stationmaps ], [], 'r0,0: departure_stationmaps'); is_deeply( [ $c0->arrival_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filename=dwa_4ED23486D.pdf'], 'r0,0: arrival_routemaps'); is_deeply( [ $c0->arrival_stationmaps ], ['http://efa.vrr.de/download/envmaps/vrr/09289_e_hbf_1.htm'], 'r0,0: arrival_stationmaps'); -is( $c0->train_line, decode( 'UTF-8', 'Straßenbahn 107' ), 'r0,0: line' ); +is( $c0->train_line, 'Straßenbahn 107', 'r0,0: line' ); is( $c0->train_destination, 'Essen Hanielstr. Schleife', 'r0,0: dest' ); is( $c0->departure_stop, 'Essen Alfredusbad', 'r0,0: dstop' ); is( $c0->departure_platform, 'Bstg. 1', 'r0,0: dplatf' ); @@ -85,7 +84,7 @@ is_deeply( ($c0->via)[0], is( $c1->delay, 3, 'r0,1: delay' ); is_deeply( [ $c1->extra ], - [ decode( 'UTF-8', 'Fahrradmitnahme begrenzt möglich' ) ], + [ 'Fahrradmitnahme begrenzt möglich' ], 'r0,1: extra' ); is_deeply( [ $c1->departure_routemaps ], ['http://efa.vrr.de/vrr/FILELOAD?Filename=dwa_4ED23486D.pdf'], 'r0,0: departure_routemaps'); @@ -105,11 +104,11 @@ is( $c1->departure_date, '27.11.2011', 'r0,1: drdate' ); is( $c1->departure_sdate, '27.11.2011', 'r0,1: dsdate' ); is( $c1->departure_time, '14:12', 'r0,1: drtime' ); is( $c1->departure_stime, '14:09', 'r0,1: dstime' ); -is( $c1->arrival_stop, decode( 'UTF-8', 'Düsseldorf Hbf' ), 'r0,1: astop' ); +is( $c1->arrival_stop, 'Düsseldorf Hbf', 'r0,1: astop' ); is( $c1->arrival_platform, 'Gleis 16', 'r0,1: aplatf' ); is( $c1->arrival_stop_and_platform, - decode( 'UTF-8', 'Düsseldorf Hbf: Gleis 16' ), + 'Düsseldorf Hbf: Gleis 16', 'r0,1: asp' ); is( $c1->arrival_date, '27.11.2011', 'r0,1: ardate' ); |