fix return of tpage
authorJoey Hess <joey@kitenet.net>
Fri, 23 Apr 2010 20:20:02 +0000 (16:20 -0400)
committerJoey Hess <joey@kitenet.net>
Fri, 23 Apr 2010 20:20:02 +0000 (16:20 -0400)
IkiWiki.pm

index 78612cd089e41aef71def2c386b7f23b5fc89ba4..7382f11e4202f4960895b447de94ee4fb55f6f09 100644 (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;
 }