summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Controller
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-10-25 17:50:00 +0100
committerDaniel Friesel <derf@finalrewind.org>2020-10-25 17:50:00 +0100
commitf8f4b9f1be84b54bedf8cf36a1c6a4ede89b362c (patch)
tree1d50e8dcadae9fed43e19695ec9312c3f7f79de6 /lib/DBInfoscreen/Controller
parentd1c5aa040038174bb7bd58b11d1f3004866e9fd0 (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.pm20
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 {