From: Joey Hess Date: Fri, 23 Apr 2010 20:20:02 +0000 (-0400) Subject: fix return of tpage X-Git-Tag: 3.20100427~41 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/96c9c8aa925120423fc563dbf233c73fc805288b fix return of tpage --- 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; }