From 88c66d375884570386855792ad6652e0ed971869 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 21 Mar 2018 09:00:41 +0000 Subject: [PATCH] meta: Make syntactically invalid dates an error If for some reason you want to create , this now requires [[!meta name="date" content="12345"]]. Signed-off-by: Simon McVittie --- IkiWiki/Plugin/meta.pm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index ea099f955..4a9852b72 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -155,14 +155,24 @@ sub preprocess (@) { eval q{use Date::Parse}; if (! $@) { my $time = str2time($value); - $IkiWiki::pagectime{$page}=$time if defined $time; + if (defined $time) { + $IkiWiki::pagectime{$page}=$time; + } + else { + error(sprintf(gettext('cannot parse date/time: %s'), $value)); + } } } elsif ($key eq 'updated') { eval q{use Date::Parse}; if (! $@) { my $time = str2time($value); - $pagestate{$page}{meta}{updated}=$time if defined $time; + if (defined $time) { + $pagestate{$page}{meta}{updated}=$time; + } + else { + error(sprintf(gettext('cannot parse date/time: %s'), $value)); + } } }