]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
meta: Make syntactically invalid dates an error
authorSimon McVittie <smcv@debian.org>
Wed, 21 Mar 2018 09:00:41 +0000 (09:00 +0000)
committerSimon McVittie <smcv@debian.org>
Wed, 21 Mar 2018 09:33:04 +0000 (09:33 +0000)
If for some reason you want to create <meta name="date" content="12345">,
this now requires [[!meta name="date" content="12345"]].

Signed-off-by: Simon McVittie <smcv@debian.org>
IkiWiki/Plugin/meta.pm

index ea099f955ac1c486cdd2baf6636e330a8eae569c..4a9852b725a83c3d86b2f1ac67ec84f5b49233e5 100644 (file)
@@ -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));
+                       }
                }
        }