summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm20
1 files 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;
}