fix return of tpage

master
Joey Hess 2010-04-23 16:20:02 -04:00
parent 7e79da7633
commit 96c9c8aa92
1 changed files with 12 additions and 8 deletions

View File

@ -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;
}