Unverified Commit 51a2b02f authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

HAFAS->new: run service check before accessing sub-keys

Thu subsequent $hafas_instance->{$service}{...} checks create
$hafas_instance->{$service}, so at that point checking for it is moot.
parent 9c41c920
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -41,6 +41,10 @@ sub new {

	my $ua = $conf{user_agent};

	if ( defined $service and not exists $hafas_instance->{$service} ) {
		confess("The service '$service' is not supported");
	}

	if ( not $ua ) {
		my %lwp_options = %{ $conf{lwp_options} // { timeout => 10 } };
		if ( $service and $hafas_instance->{$service}{ua_string} ) {
@@ -79,10 +83,6 @@ sub new {
		confess("You must specify a service");
	}

	if ( defined $service and not exists $hafas_instance->{$service} ) {
		confess("The service '$service' is not supported");
	}

	my $now = DateTime->now( time_zone => $hafas_instance->{$service}{time_zone}
		  // 'Europe/Berlin' );
	my $self = {