]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/bugreport.cgi
[project @ 2005-07-16 18:49:31 by don]
[debbugs.git] / cgi / bugreport.cgi
index c287311e4de2379424e6fe3aa9ae1924cb3846f1..f46cad8cc051da760ceee1b1851617cee8d66041 100755 (executable)
@@ -43,7 +43,7 @@ set_option('repeatmerged', $repeatmerged);
 my $buglog = buglog($ref);
 
 if ($ENV{REQUEST_METHOD} eq 'HEAD' and not defined($att) and not $mbox) {
-    print "Content-Type: text/html\n";
+    print "Content-Type: text/html; charset=utf-8\n";
     my @stat = stat $buglog;
     if (@stat) {
        my $mtime = strftime '%a, %d %b %Y %T GMT', gmtime($stat[9]);
@@ -68,9 +68,11 @@ sub display_entity ($$$$\$\@) {
     my $type = $entity->effective_type;
     my $filename = $entity->head->recommended_filename;
     $filename = '' unless defined $filename;
+    $filename = decode_rfc1522($filename);
 
     if ($top) {
-       $$this .= htmlsanit($entity->stringify_header) unless ($terse);
+       $$this .= htmlsanit(decode_rfc1522($entity->stringify_header))
+           unless ($terse);
        $$this .= "\n";
     }
 
@@ -88,9 +90,14 @@ sub display_entity ($$$$\$\@) {
            my $head = $entity->head;
            chomp(my $type = $entity->effective_type);
            my $body = $entity->stringify_body;
-           print "Content-Type: $type";
-           print "; name=$filename" if $filename ne '';
-           print "\n\n";
+           print "Content-Type: $type\n";
+           if ($filename ne '') {
+               my $qf = $filename;
+               $qf =~ s/"/\\"/g;
+               $qf =~ s[.*/][];
+               print qq{Content-Disposition: attachment; filename="$qf"\n};
+           }
+           print "\n";
            my $decoder = new MIME::Decoder($head->mime_encoding);
            $decoder->decode(new IO::Scalar(\$body), \*STDOUT);
            exit(0);
@@ -98,7 +105,8 @@ sub display_entity ($$$$\$\@) {
     }
 
     return if not $top and $disposition eq 'attachment' and not defined($att);
-    return unless ($type =~ m[^text/?] and $type !~ m[^text/html(?:;|$)]) or
+    return unless ($type =~ m[^text/?] and
+                  $type !~ m[^text/(?:html|enriched)(?:;|$)]) or
                  $type =~ m[^application/pgp(?:;|$)] or
                  $entity->parts;
 
@@ -144,7 +152,7 @@ $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
 my %status = %{getbugstatus($ref)};
 unless (%status) {
     print <<EOF;
-Content-Type: text/html
+Content-Type: text/html; charset=utf-8
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
@@ -174,8 +182,8 @@ if  ($status{severity} eq 'normal') {
 $indexentry .= "<p>$showseverity";
 $indexentry .= htmlpackagelinks($status{package}, 0);
 
-$indexentry .= "Reported by: <a href=\"" . submitterurl($status{originator})
-              . "\">" . htmlsanit($status{originator}) . "</a>;\n";
+$indexentry .= htmladdresslinks("Reported by: ", \&submitterurl,
+                                $status{originator}) . ";\n";
 
 $indexentry .= "Owned by: " . htmlsanit($status{owner}) . ";\n"
               if length $status{owner};
@@ -238,7 +246,14 @@ foreach my $pkg (@tpacks) {
     $descriptivehead .= ".\n<br>";
 }
 
-open L, "<$buglog" or &quitcgi("open log for $ref: $!");
+if ($buglog =~ m/\.gz$/) {
+    my $oldpath = $ENV{'PATH'};
+    $ENV{'PATH'} = '/bin:/usr/bin';
+    open L, "zcat $buglog |" or &quitcgi("open log for $ref: $!");
+    $ENV{'PATH'} = $oldpath;
+} else {
+    open L, "<$buglog" or &quitcgi("open log for $ref: $!");
+}
 if ($buglog !~ m#^\Q$gSpoolDir/db#) {
     $descriptivehead .= "\n<p>Bug is <strong>archived</strong>. No further changes may be made.</p>";
 }
@@ -435,7 +450,7 @@ if ( $mbox ) {
        print join("", @mails );
        exit 0;
 }
-print "Content-Type: text/html\n\n";
+print "Content-Type: text/html; charset=utf-8\n\n";
 
 my $title = htmlsanit($status{subject});