diff options
| author | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-24 20:07:11 +0200 | 
|---|---|---|
| committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2025-06-24 20:07:11 +0200 | 
| commit | 24cac5daf84df820798c445af19522cfaab00904 (patch) | |
| tree | 6ce6ce4476071e71b4265345482d15fe8bcd0b6d /lib/Travelynx/Controller/Traveling.pm | |
| parent | 9e6728a3e14fbe48b7e7aa1d7c0ae2d4e79f0ece (diff) | |
add_intransit_form: add simple sanity check for route timestamps
Diffstat (limited to 'lib/Travelynx/Controller/Traveling.pm')
| -rwxr-xr-x | lib/Travelynx/Controller/Traveling.pm | 17 | 
1 files changed, 15 insertions, 2 deletions
| diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index a5c91df..fd2abb1 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -2710,6 +2710,7 @@ sub add_intransit_form {  		if ( $trip{route} ) {  			my @unknown_stations; +			my $prev_epoch;  			for my $station ( @{ $trip{route} } ) {  				my $ts;  				my %station_data; @@ -2719,8 +2720,20 @@ sub add_intransit_form {  				{  					$station = $+{stop};  					$ts      = $parser->parse_datetime( $+{timestamp} ); -					$station_data{sched_arr} = $ts->epoch; -					$station_data{sched_dep} = $ts->epoch; +					if ( $ts and $ts->epoch > $prev_epoch ) { +						$station_data{sched_arr} = $ts->epoch; +						$station_data{sched_dep} = $ts->epoch; +						$prev_epoch              = $ts->epoch; +					} +					else { +						$self->render( +							'add_intransit', +							with_autocomplete => 1, +							status            => 400, +							error => "Ungültige Zeitangabe: $+{timestamp}" +						); +						return; +					}  				}  				my $station_info = $self->stations->search( $station,  					backend_id => $opt{backend_id} ); | 
