]> git.donarmstrong.com Git - debbugs.git/blob - cgi/bugreport.cgi
[project @ 1999-09-20 05:40:06 by gecko]
[debbugs.git] / cgi / bugreport.cgi
1 #!/usr/bin/perl -w
2
3 package debbugs;
4
5 use strict;
6 use CGI qw/:standard/;
7
8 require '/usr/lib/debbugs/errorlib';
9 require '/usr/lib/debbugs/common.pl';
10
11 require '/etc/debbugs/config';
12 require '/etc/debbugs/text';
13
14 my $dtime;
15 my $tail_html;
16
17 my %maintainer = getmaintainers();
18
19 my $ref= param('bug') || die("No bug number");
20 my $archive = (param('archive') || 'no') eq 'yes';
21 my %status = getbugstatus($ref, $archive);
22
23 my $msg = param('msg') || "";
24 my $boring = (param('boring') || 'no') eq 'yes'; 
25 my $reverse = (param('reverse') || 'no') eq 'yes';
26
27 my $indexentry;
28 my $descriptivehead;
29 my $submitted;
30 my $showseverity;
31
32 my $tpack;
33 my $tmain;
34
35 $dtime=`date -u '+%H:%M:%S GMT %a %d %h'`;
36 chomp($dtime);
37
38 $tail_html = $debbugs::gHTMLTail;
39 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
40
41 $|=1;
42
43 $tpack = lc $status{package};
44 $tpack =~ s/[^-+._a-z0-9()].*$//;
45
46 if  ($status{severity} eq 'normal') {
47         $showseverity = '';
48 #} elsif (grep($status{severity} eq $_, @strongseverities)) {
49 #       $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
50 } else {
51         $showseverity = "Severity: <em>$status{severity}</em>;\n";
52 }
53
54 $indexentry .= $showseverity;
55 $indexentry .= "Reported by: ".&sani($status{originator});
56 $indexentry .= ";\nKeywords: ".&sani($status{keywords}) 
57                         if length($status{keywords});
58
59 my @merged= split(/ /,$status{mergedwith});
60 if (@merged) {
61         my $mseparator= ";\nmerged with ";
62         for my $m (@merged) {
63                 $indexentry .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
64                 $mseparator= ",\n";
65         }
66 }
67
68 $submitted = `TZ=GMT LANG=C \\
69                 date -d '1 Jan 1970 00:00:00 + $status{date} seconds' \\
70                 '+ %a, %d %b %Y %T %Z'`;
71
72 if (length($status{done})) {
73         $indexentry .= ";\n<strong>Done:</strong> ".&sani($status{done});
74 } elsif (length($status{forwarded})) {
75         $indexentry .= ";\n<strong>Forwarded</strong> to ".&sani($status{forwarded});
76 }
77
78 my ($short, $tmaint);
79 $short = $ref; $short =~ s/^\d+/#$&/;
80 $tmaint = defined($maintainer{$tpack}) ? $maintainer{$tpack} : '(unknown)';
81 $descriptivehead= $indexentry.$submitted.";\nMaintainer for $status{package} is\n".
82             '<A href="http://'.$debbugs::gWebDomain.'/ma/l'.&maintencoded($tmaint).'.html">'.&sani($tmaint).'</A>.';
83
84 my $buglog = buglog($ref, $archive);
85 open L, "<$buglog" || &quit("open log for $ref: $!");
86
87 my $log='';
88
89 my $xmessage = 1;
90 my $suppressnext = 0;
91
92 my $this = '';
93
94 my $cmsg = 1;
95
96 my $normstate= 'kill-init';
97 my $linenum = 0;
98 while(my $line = <L>) {
99         $linenum++;
100         if ($line =~ m/^.$/ and 1 <= ord($line) && ord($line) <= 7) {
101                 # state transitions
102                 my $newstate;
103                 my $statenum = ord($line);
104
105                 $newstate = 'autocheck'     if ($statenum == 1);
106                 $newstate = 'recips'        if ($statenum == 2);
107                 $newstate = 'kill-end'      if ($statenum == 3);
108                 $newstate = 'go'            if ($statenum == 5);
109                 $newstate = 'html'          if ($statenum == 6);
110                 $newstate = 'incoming-recv' if ($statenum == 7);
111
112                 # disallowed transitions:
113                 $_ = "$normstate $newstate";
114                 unless (m/^(go|go-nox|html) kill-end$/
115                     || m/^(kill-init|kill-end) (incoming-recv|autocheck|recips|html)$/
116                     || m/^kill-body go$/)
117                 {
118                         &quit("$ref: Transition from $normstate to $newstate at $linenum disallowed");
119                 }
120
121                 if ($newstate eq 'go') {
122                         $this .= "<pre>\n";
123                 }
124
125                 if ($newstate eq 'html') {
126                         $this = '';
127                 }
128
129                 if ($newstate eq 'kill-end') {
130
131                         $this .= "</pre>\n"
132                                 if $normstate eq 'go' || $normstate eq 'go-nox';
133
134                         if ($normstate eq 'html') {
135                                 $this .= "  <em><A href=\"" . bugurl($ref, "msg=$xmessage", "archive=$archive") . "\">Full text</A> available.</em>";
136                         }
137
138                         my $show = 1;
139                         $show = $boring
140                                 if ($suppressnext && $normstate ne 'html');
141
142                         $show = ($xmessage == $msg) if ($msg);
143
144                         if ($show) {
145                                 if ($reverse) {
146                                         $log = "$this\n<hr>$log";
147                                 } else {
148                                         $log .= "$this\n<hr>\n";
149                                 }
150                         }
151
152                         $xmessage++ if ($normstate ne 'html');
153
154                         $suppressnext = $normstate eq 'html';
155                 }
156                 
157                 $normstate = $newstate;
158                 next;
159         }
160
161         $_ = $line;
162         if ($normstate eq 'incoming-recv') {
163                 my $pl= $_;
164                 $pl =~ s/\n+$//;
165                 m/^Received: \(at (\S+)\) by (\S+)\;/
166                         || &quit("bad line \`$pl' in state incoming-recv");
167                 $this = "<h2>Message received at ".&sani("$1\@$2")
168                         . ":</h2><br>\n<pre>\n$_";
169                 $normstate= 'go';
170         } elsif ($normstate eq 'html') {
171                 $this .= $_;
172         } elsif ($normstate eq 'go') {
173                 $this .= &sani($_);
174         } elsif ($normstate eq 'go-nox') {
175                 next if !s/^X//;
176                 $this .= &sani($_);
177         } elsif ($normstate eq 'recips') {
178                 if (m/^-t$/) {
179                         $this = "<h2>Message sent:</h2><br>\n";
180                 } else {
181                         s/\04/, /g; s/\n$//;
182                         $this = "<h2>Message sent to ".&sani($_).":</h2><br>\n";
183                 }
184                 $normstate= 'kill-body';
185         } elsif ($normstate eq 'autocheck') {
186                 next if !m/^X-Debian-Bugs(-\w+)?: This is an autoforward from (\S+)/;
187                 $normstate= 'autowait';
188                 $this = "<h2>Message received at $2:</h2><br>\n";
189         } elsif ($normstate eq 'autowait') {
190                 next if !m/^$/;
191                 $normstate= 'go-nox';
192                 $this .= "<pre>\n";
193         } else {
194                 &quit("$ref state $normstate line \`$_'");
195         }
196 }
197 &quit("$ref state $normstate at end") unless $normstate eq 'kill-end';
198 close(L);
199
200 print header;
201 print start_html("$debbugs::gProject $debbugs::gBug report logs - $short");
202
203 print h1("$debbugs::gProject $debbugs::gBug report logs -  $short<br>\n"
204         . sani($status{subject}));
205
206 print "$descriptivehead\n";
207 print hr;
208 print "$log";
209 print $tail_html;
210
211 print end_html;
212
213 sub maintencoded {
214         return "";
215 }
216
217 exit 0;