diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-10-25 17:50:00 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-10-25 17:50:00 +0100 |
commit | f8f4b9f1be84b54bedf8cf36a1c6a4ede89b362c (patch) | |
tree | 1d50e8dcadae9fed43e19695ec9312c3f7f79de6 /lib/DBInfoscreen/Controller | |
parent | d1c5aa040038174bb7bd58b11d1f3004866e9fd0 (diff) |
fix HTTP 500 on invalid via RE; improve via handling while at it3.4.8
Diffstat (limited to 'lib/DBInfoscreen/Controller')
-rw-r--r-- | lib/DBInfoscreen/Controller/Stationboard.pm | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/DBInfoscreen/Controller/Stationboard.pm b/lib/DBInfoscreen/Controller/Stationboard.pm index c6f697f..715f33a 100644 --- a/lib/DBInfoscreen/Controller/Stationboard.pm +++ b/lib/DBInfoscreen/Controller/Stationboard.pm @@ -90,10 +90,26 @@ sub result_has_via { my @route = $result->route_post; - if ( List::MoreUtils::any { m{$via}i } @route ) { + my $eq_result = List::MoreUtils::any { lc eq lc($via) } @route; + + if ($eq_result) { return 1; } - return 0; + + my ( $re1_result, $re2_result ); + + eval { + $re2_result = List::MoreUtils::any { m{\Q$via\E}i } @route; + }; + eval { + $re1_result = List::MoreUtils::any { m{$via}i } @route; + }; + + if ($@) { + return $re2_result || $eq_result; + } + + return $re1_result || $re2_result || $eq_result; } sub log_api_access { |