yangtse: curl-www/auto logdnld.cgi,1.1,1.2

[email protected]
Newsgroups gmane.comp.web.curl.www.cvs
Message-ID <[email protected]>
Update of /cvsroot/curl/curl-www/auto
In directory labb:/tmp/cvs-serv4840/auto

Modified Files:
	logdnld.cgi 
Log Message:
fail more gracefully when file does not exist

Index: logdnld.cgi
===================================================================
RCS file: /cvsroot/curl/curl-www/auto/logdnld.cgi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- logdnld.cgi	14 Mar 2007 19:30:48 -0000	1.1
+++ logdnld.cgi	15 Mar 2007 02:57:47 -0000	1.2
@@ -5,22 +5,44 @@
 use strict;
 
 require "CGI.pm";
+require "../curl.pm";
 
 my $req = new CGI;
 
+my $id = "";
+my $year = "";
+my $month = "";
+my $day = "";
+
 my $fname = $req->path_info();
 
 # Strip invalid characters from single build log filename
 $fname =~ s/[^-0-9_a-zA-Z\.]//g;
 
+sub logdnld_file_not_found {
+    print "Content-Type: text/html\n\n";
+    header("Autobuilds - single log download");
+    where("Autobuilds", "/auto", "Log From $year-$month-$day",
+          "/auto/log.cgi?id=$id", "Download");
+    title("Download log from $year-$month-$day");
+    print "File not found!";
+    &catfile("foot.html");
+}
+
 # Validate single build log filename format
-exit(0) unless ($fname =~ /^build-(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)-(\d+)\.log$/);
+if($fname =~ /^build-(\d\d\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)-(\d+)\.log$/) {
+    my ($bhour, $bmin, $bsec, $bpid);
+    ($year, $month, $day, $bhour, $bmin, $bsec, $bpid)=
+        ($1, $2, $3, $4, $5, $6, $7);
+    $id = "$year$month$day$bhour$bmin$bsec-$bpid";
+}
+else {
+    logdnld_file_not_found();
+    exit(0);
+}
 
 my $build = "inbox/$fname";
 
-# Verify file exists
-exit(0) unless (-f $build);
-
 if(open(my $logfile, "<$build")) {
     #
     my $buffer;
@@ -41,4 +63,8 @@
     #
     close($logfile);
 }
+else {
+    logdnld_file_not_found();
+    exit(0);
+}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.