summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerf Null <derf@finalrewind.org>2023-06-04 19:37:16 +0200
committerDerf Null <derf@finalrewind.org>2023-06-04 19:37:16 +0200
commitab04bc19b9694d906125345e516c89fd0c4626f1 (patch)
treec65c4301504e28383c89b37d7357fad86782d1ca
parentc1635e24fb78d981a790463cfe35ba552bcaac04 (diff)
consistently return HTTP 404 on not found errors
-rwxr-xr-xlib/Travelynx/Controller/Profile.pm8
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm33
2 files changed, 26 insertions, 15 deletions
diff --git a/lib/Travelynx/Controller/Profile.pm b/lib/Travelynx/Controller/Profile.pm
index b11dd71..1e29748 100755
--- a/lib/Travelynx/Controller/Profile.pm
+++ b/lib/Travelynx/Controller/Profile.pm
@@ -66,7 +66,7 @@ sub profile {
my $user = $self->users->get_privacy_by( name => $name );
if ( not $user ) {
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
return;
}
@@ -437,11 +437,11 @@ sub user_status {
"/p/${name}/j/$journey->{id}?token=${token}-${ts}");
}
else {
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
}
return;
}
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
return;
}
@@ -550,7 +550,7 @@ sub status_card {
delete $self->stash->{layout};
if ( not $user ) {
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
return;
}
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 80214ab..2463bb5 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -1222,7 +1222,7 @@ sub year_in_review {
# -> Limit time range to avoid accidental DoS.
if ( not( $year =~ m{ ^ [0-9]{4} $ }x and $year > 1990 and $year < 2100 ) )
{
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
return;
}
@@ -1244,8 +1244,11 @@ sub year_in_review {
);
if ( not @journeys ) {
- $self->render( 'not_found',
- message => 'Keine Zugfahrten im angefragten Jahr gefunden.' );
+ $self->render(
+ 'not_found',
+ message => 'Keine Zugfahrten im angefragten Jahr gefunden.',
+ status => 404
+ );
return;
}
@@ -1253,9 +1256,11 @@ sub year_in_review {
if (
not( $year < $now->year or ( $now->month == 12 and $now->day == 31 ) ) )
{
- $self->render( 'not_found',
+ $self->render(
+ 'not_found',
message =>
-'Der aktuelle Jahresrückblick wird erst zum Jahresende (am 31.12.) freigeschaltet'
+'Der aktuelle Jahresrückblick wird erst zum Jahresende (am 31.12.) freigeschaltet',
+ status => 404
);
return;
}
@@ -1287,7 +1292,7 @@ sub yearly_history {
# -> Limit time range to avoid accidental DoS.
if ( not( $year =~ m{ ^ [0-9]{4} $ }x and $year > 1990 and $year < 2100 ) )
{
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
return;
}
my $interval_start = DateTime->new(
@@ -1312,8 +1317,11 @@ sub yearly_history {
}
if ( not @journeys ) {
- $self->render( 'not_found',
- message => 'Keine Zugfahrten im angefragten Jahr gefunden.' );
+ $self->render(
+ 'not_found',
+ status => 404,
+ message => 'Keine Zugfahrten im angefragten Jahr gefunden.'
+ );
return;
}
@@ -1365,7 +1373,7 @@ sub monthly_history {
and $month < 13 )
)
{
- $self->render('not_found');
+ $self->render( 'not_found', status => 404 );
return;
}
my $interval_start = DateTime->new(
@@ -1386,8 +1394,11 @@ sub monthly_history {
);
if ( not @journeys ) {
- $self->render( 'not_found',
- message => 'Keine Zugfahrten im angefragten Monat gefunden.' );
+ $self->render(
+ 'not_found',
+ message => 'Keine Zugfahrten im angefragten Monat gefunden.',
+ status => 404
+ );
return;
}