From 86c30dcd6b010f143f05bae367b8acb84e0f6cee Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 1 May 2020 16:55:09 +0200 Subject: Fix VOR and LinzAG encoding --- bin/efa-m | 5 ++++- lib/Travel/Status/DE/EFA.pm | 39 ++++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/bin/efa-m b/bin/efa-m index 7e84863..93c6b6b 100755 --- a/bin/efa-m +++ b/bin/efa-m @@ -16,6 +16,7 @@ use List::Util qw(first max); use Travel::Status::DE::EFA; my $efa_url = 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST'; +my $efa_encoding; my ( $date, $time, $input_type, $list_lines, $offset, $relative_times ); my ($full_routes); my ( $filter_via, $track_via ); @@ -95,7 +96,8 @@ if ($service) { ); exit 1; } - $efa_url = $service_ref->{url}; + $efa_url = $service_ref->{url}; + $efa_encoding = $service_ref->{encoding}; } sub new_efa_by_url { @@ -104,6 +106,7 @@ sub new_efa_by_url { date => $date, developer_mode => $developer_mode, efa_url => $url, + efa_encoding => $efa_encoding, full_routes => $full_routes, place => $place, name => $input, diff --git a/lib/Travel/Status/DE/EFA.pm b/lib/Travel/Status/DE/EFA.pm index a77baac..71775a4 100644 --- a/lib/Travel/Status/DE/EFA.pm +++ b/lib/Travel/Status/DE/EFA.pm @@ -126,7 +126,12 @@ sub new { return $self; } - $self->{xml} = $response->decoded_content; + if ( $opt{efa_encoding} ) { + $self->{xml} = encode( $opt{efa_encoding}, $response->content ); + } + else { + $self->{xml} = $response->decoded_content; + } if ( not $self->{xml} ) { @@ -534,6 +539,7 @@ sub get_efa_urls { url => 'https://efa.vor.at/wvb/XSLT_DM_REQUEST', name => 'Verkehrsverbund Ost-Region', shortname => 'VOR', + encoding => 'iso-8859-15', }, # HTTPS not supported @@ -546,6 +552,7 @@ sub get_efa_urls { url => 'https://www.linzag.at/static/XSLT_DM_REQUEST', name => 'Linz AG', shortname => 'LinzAG', + encoding => 'iso-8859-15', }, { url => 'https://efa.vgn.de/vgnExt_oeffi/XML_DM_REQUEST', @@ -643,7 +650,7 @@ Travel::Status::DE::EFA - unofficial EFA departure monitor use Travel::Status::DE::EFA; my $status = Travel::Status::DE::EFA->new( - efa_url => 'http://efa.vrr.de/vrr/XSLT_DM_REQUEST', + efa_url => 'https://efa.vrr.de/vrr/XSLT_DM_REQUEST', place => 'Essen', name => 'Helenenstr' ); @@ -672,7 +679,8 @@ It reports all upcoming tram/bus/train departures at a given place. =item my $status = Travel::Status::DE::EFA->new(I<%opt>) Requests the departures as specified by I and returns a new -Travel::Status::DE::EFA object. Dies if the wrong I were passed. +Travel::Status::DE::EFA object. B, B and B are +mandatory. Dies if the wrong I were passed. Arguments: @@ -680,20 +688,9 @@ Arguments: =item B => I -URL to the EFA service. Known URLs are: - -=over - -=item * L (Verkehrsverbund GroEraum NErnberg) - -=item * L (Verkehrsverbund Rhein-Ruhr) - -=item * L (Verkehrsverbund Stuttgart) - -=back - -If you found a URL not listed here, please send it to -Ederf@finalrewind.orgE. +URL to the EFA service. See C<< efa-m --list >> for known URLs. +If you found a URL not listed there, please notify +Ederf+efa@finalrewind.orgE. =item B => I @@ -708,6 +705,12 @@ B (stop/station name). address / poi / stop name to list departures for. +=item B => I + +Some EFA servers do not correctly specify their response encoding. If you +observe encoding issues, you can manually specify it here. Example: +iso-8859-15. + =item B => B<0>|B<1> If true: Request full routes for all departures from the backend. This @@ -765,6 +768,8 @@ the following elements. =item B: Short name of the entity +=item B: Server-side encoding override for B (optional) + =back =back -- cgit v1.2.3