]> sipb.mit.edu Git - ikiwiki.git/commitdiff
avoid perl warning when passed bad non-numeric year/month/day
authorJoey Hess <joey@kitenet.net>
Wed, 20 Oct 2010 22:52:46 +0000 (18:52 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 20 Oct 2010 22:52:46 +0000 (18:52 -0400)
IkiWiki.pm

index 2190f008c483bc4d0b715706b322de9a6b9317f6..941ee13c4d7cb6d7a76ea9643b133977f092e5e1 100644 (file)
@@ -2608,6 +2608,10 @@ sub match_created_after ($$;@) {
 }
 
 sub match_creation_day ($$;@) {
+       my $d=shift;
+       if ($d !~ /^\d+$/) {
+               return IkiWiki::FailReason->new('invalid day');
+       }
        if ((localtime($IkiWiki::pagectime{shift()}))[3] == shift) {
                return IkiWiki::SuccessReason->new('creation_day matched');
        }
@@ -2617,6 +2621,10 @@ sub match_creation_day ($$;@) {
 }
 
 sub match_creation_month ($$;@) {
+       my $m=shift;
+       if ($m !~ /^\d+$/) {
+               return IkiWiki::FailReason->new('invalid month');
+       }
        if ((localtime($IkiWiki::pagectime{shift()}))[4] + 1 == shift) {
                return IkiWiki::SuccessReason->new('creation_month matched');
        }
@@ -2626,7 +2634,11 @@ sub match_creation_month ($$;@) {
 }
 
 sub match_creation_year ($$;@) {
-       if ((localtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift) {
+       my $y=shift;
+       if ($y !~ /^\d+$/) {
+               return IkiWiki::FailReason->new('invalid year');
+       }
+       if ((localtime($IkiWiki::pagectime{shift()}))[5] + 1900 == $y) {
                return IkiWiki::SuccessReason->new('creation_year matched');
        }
        else {