]> git.deb.at Git - pkg/blosxom.git/blobdiff - blosxom.cgi
syntax error fix
[pkg/blosxom.git] / blosxom.cgi
index 997fcc74a4a00fdc80eb0cd82265e8c64f850643..2fd086149ff63fd7838de45be2f1c6a431901f4f 100755 (executable)
@@ -143,13 +143,20 @@ $template =
       return join '', <$fh> if $fh->open("< $datadir/$path/$chunk.$flavour");
     } while ($path =~ s/(\/*[^\/]*)$// and $1);
 
-    return join '', ($template{$flavour}{$chunk} || $template{error}{$chunk} || '');
+    # Check for definedness, since flavour can be the empty string
+    if (defined $template{$flavour}{$chunk}) {
+       return $template{$flavour}{$chunk};
+    } elsif (defined $template{error}{$chunk}) {
+       return $template{error}{$chunk} 
+    } else {
+       return '';
+    }
   };
 # Bring in the templates
 %template = ();
 while (<DATA>) {
   last if /^(__END__)$/;
-  my($ct, $comp, $txt) = /^(\S+)\s(\S+)\s(.*)$/ or next;
+  my($ct, $comp, $txt) = /^(\S+)\s(\S+)(?:\s(.*))?$/ or next;
   $txt =~ s/\\n/\n/mg;
   $template{$ct}{$comp} .= $txt . "\n";
 }
@@ -176,7 +183,7 @@ sub load_template {
   return &$template(@_);
 }
 
-# Define default entries subroutine
+# Define default find subroutine
 $entries =
   sub {
     my(%files, %indexes, %others);
@@ -356,7 +363,7 @@ sub generate {
       ($path,$fn) = $path_file =~ m!^$datadir/(?:(.*)/)?(.*)\.$file_extension!;
   
       # Only stories in the right hierarchy
-      $path =~ /^$currentdir/ or $path_file eq "$datadir/$currentdir" or next;
+      $path =~ /^$currentdir(?=$|\/)/ or $path_file eq "$datadir/$currentdir" or next;
   
       # Prepend a slash for use in templates only if a path exists
       $path &&= "/$path";