From 96c9c8aa925120423fc563dbf233c73fc805288b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 23 Apr 2010 16:20:02 -0400 Subject: [PATCH] fix return of tpage --- IkiWiki.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 78612cd08..7382f11e4 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1661,16 +1661,20 @@ sub template_file ($) { } my $template=srcfile($tpage, 1); - if (defined $template) { - return $template, $tpage if wantarray; - return $template; + if (! defined $template) { + $name=~s:/::; # avoid path traversal + foreach my $dir ($config{templatedir}, + "$installdir/share/ikiwiki/templates") { + if (-e "$dir/$name") { + $template="$dir/$name"; + last; + } + } } - $name=~s:/::; # avoid path traversal - - foreach my $dir ($config{templatedir}, - "$installdir/share/ikiwiki/templates") { - return "$dir/$name" if -e "$dir/$name"; + if (defined $template) { + return $template, $tpage if wantarray; + return $template; } return; } -- 2.39.5