give a meaningful error if it is empty and disallow it instead of having
an implicit default (the default should be set by the component using
the calendarevent, not the calendarevent itself)
also add regression tests
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
use Data::Dumper;
use Time::Local;
use PVE::JSONSchema;
+use PVE::Tools qw(trim);
# Note: This class implements a parser/utils for systemd like calender exents
# Date specification is currently not implemented
sub parse_calendar_event {
my ($event) = @_;
+ $event = trim($event);
+
+ if ($event eq '') {
+ die "unable to parse calendar event - event is empty\n";
+ }
+
my $parse_single_timespec = sub {
my ($p, $max, $matchall_ref, $res_hash) = @_;
'0..80',
{ error => "range end '80' out of range" },
],
+ [
+ ' mon 0 0 0',
+ { error => "unable to parse calendar event - unused parts" },
+ ],
+ [
+ '',
+ { error => "unable to parse calendar event - event is empty" },
+ ],
+ [
+ ' mon 0 0',
+ { error => "unable to parse calendar event - unused parts" },
+ ],
];
foreach my $test (@$tests) {