From 4a75dee651390b79ce4ceb1d951b02e28b3ce83a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 20 Oct 2010 18:52:46 -0400 Subject: avoid perl warning when passed bad non-numeric year/month/day --- IkiWiki.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 2190f008c..941ee13c4 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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 { -- cgit v1.2.3