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