]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/service.in
add fixed and notfixed commands
[debbugs.git] / scripts / service.in
index 1781ebac986d9997177353322d6ebcd0e5640fbb..d4e8e98ed6d066bab95db98f659567d0f40a6c1b 100755 (executable)
@@ -1,17 +1,19 @@
 #!/usr/bin/perl
-# $Id: service.in,v 1.80 2003/07/15 13:03:33 ajt Exp $
-# ^ more or less ^
+# $Id: service.in,v 1.118 2005/10/19 01:22:14 don Exp $
 #
 # Usage: service <code>.nn
 # Temps:  incoming/P<code>.nn
 
 use File::Copy;
 use MIME::Parser;
-
-$config_path = '/etc/debbugs';
-$lib_path = '/usr/lib/debbugs';
-
-require "$config_path/config";
+use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
+use Debbugs::Mail qw(send_mail_message);
+use Debbugs::User;
+use HTML::Entities qw(encode_entities);
+
+use Debbugs::Config qw(:globals :config);
+use Debbugs::CGI qw(html_escape);
+$lib_path = $gLibPath;
 require "$lib_path/errorlib";
 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
 
@@ -47,6 +49,9 @@ my $entity = eval { $parser->parse_data(join('',@log)) };
 
 # header and decoded body respectively
 my (@headerlines, @bodylines);
+# Bug numbers to send e-mail to, hash so that we don't send to the
+# same bug twice.
+my (%bug_affected);
 
 if ($entity and $entity->head->tags) {
     @headerlines = @{$entity->head->header};
@@ -72,6 +77,7 @@ if ($entity and $entity->head->tags) {
 }
 
 for (@headerlines) {
+    $_ = decode_rfc1522($_);
     s/\n\s/ /g;
     print ">$_<\n" if $debug;
     if (s/^(\S+):\s*//) {
@@ -115,6 +121,8 @@ if ( defined($header{'reply-to'}) && $header{'reply-to'} ne "" ) {
     $replyto = $header{'from'};
 }
 
+# This is an error counter which should be incremented every time there is an error.
+my $errors = 0;
 $controlrequestaddr= $control ? "control\@$gEmailDomain" : "request\@$gEmailDomain";
 $transcript='';
 &transcript("Processing commands for $controlrequestaddr:\n\n");
@@ -126,6 +134,13 @@ $mergelowstate= 'idle';
 $midix=0;    
 $extras="";
 
+my $user = $replyto;
+$user =~ s/,.*//;
+$user =~ s/^.*<(.*)>.*$/$1/;
+$user =~ s/[(].*[)]//;
+$user =~ s/^\s*(\S+)\s+.*$/$1/;
+$user = "" unless (Debbugs::User::is_valid_user($user));
+
 my $quickabort = 0;
 
 my $fuckheads = "(" . join("|", @gFuckheads) . ")";
@@ -138,6 +153,10 @@ my %limit_pkgs = ();
 my %clonebugs = ();
 my @bcc = ();
 
+sub addbcc {
+    push @bcc, $_[0] unless grep { $_ eq $_[0] } @bcc;
+}
+
 for ($procline=0; $procline<=$#bodylines; $procline++) {
     $state eq 'idle' || print "$state ?\n";
     $lowstate eq 'idle' || print "$lowstate ?\n";
@@ -151,7 +170,7 @@ for ($procline=0; $procline<=$#bodylines; $procline++) {
     &transcript("> $_\n");
     next if m/^\s*\#/;
     $action= '';
-    if (m/^stop/i || m/^quit/i || m/^--/ || m/^thank/i) {
+    if (m/^stop\s*$/i || m/^quit\s*$/i || m/^--\s*$/ || m/^thank(?:s|\s*you)?\s*$/i || m/^kthxbye\s*$/i) {
        &transcript("Stopping processing here.\n\n");
         last;
     } elsif (m/^debug\s+(\d+)$/i && $1 >= 0 && $1 <= 1000) {
@@ -166,12 +185,15 @@ for ($procline=0; $procline<=$#bodylines; $procline++) {
                     "detailed logs for $gBug#$ref");
     } elsif (m/^index(\s+full)?$/i) {
        &transcript("This BTS function is currently disabled, sorry.\n\n");
+       $errors++;
        $ok++; # well, it's not really ok, but it fixes #81224 :)
     } elsif (m/^index-summary\s+by-package$/i) {
        &transcript("This BTS function is currently disabled, sorry.\n\n");
+       $errors++;
        $ok++; # well, it's not really ok, but it fixes #81224 :)
     } elsif (m/^index-summary(\s+by-number)?$/i) {
        &transcript("This BTS function is currently disabled, sorry.\n\n");
+       $errors++;
        $ok++; # well, it's not really ok, but it fixes #81224 :)
     } elsif (m/^index(\s+|-)pack(age)?s?$/i) {
        &sendlynxdoc("pkgindex.cgi?indexon=pkg",'index of packages');
@@ -189,12 +211,15 @@ for ($procline=0; $procline<=$#bodylines; $procline++) {
         $ok++;
     } elsif (m/^send-unmatched(\s+this|\s+-?0)?$/i) {
        &transcript("This BTS function is currently disabled, sorry.\n\n");
+       $errors++;
        $ok++; # well, it's not really ok, but it fixes #81224 :)
     } elsif (m/^send-unmatched\s+(last|-1)$/i) {
        &transcript("This BTS function is currently disabled, sorry.\n\n");
+       $errors++;
        $ok++; # well, it's not really ok, but it fixes #81224 :)
     } elsif (m/^send-unmatched\s+(old|-2)$/i) {
        &transcript("This BTS function is currently disabled, sorry.\n\n");
+       $errors++;
        $ok++; # well, it's not really ok, but it fixes #81224 :)
     } elsif (m/^getinfo\s+([\w-.]+)$/i) {
         # the following is basically a Debian-specific kludge, but who cares
@@ -227,32 +252,183 @@ END
 soon: UNSUBSCRIBE_TEXT
 soon: MAILINGLISTS_TEXT
 END
+    } elsif (m/^user\s+(\S+)\s*$/i) {
+        my $newuser = $1;
+       if (Debbugs::User::is_valid_user($newuser)) {
+           my $olduser = ($user ne "" ? " (was $user)" : "");
+            &transcript("Setting user to $newuser$olduser.\n");
+           $user = $newuser;
+       } else {
+           &transcript("Selected user id ($newuser) invalid, sorry\n");
+           $errors++;
+           $user = "";
+       }
+    } elsif (m/^usercategory\s+(\S+)(\s+\[hidden\])?\s*$/i) {
+        $ok++;
+       my $catname = $1;
+       my $hidden = ($2 ne "");
+
+        my $prefix = "";
+        my @cats;
+        my $bad = 0;
+       my $catsec = 0;
+        while (++$procline <= $#bodylines) {
+            unless ($bodylines[$procline] =~ m/^\s*([*+])\s*(\S.*)$/) {
+                $procline--;
+                last;
+            }
+            &transcript("> $bodylines[$procline]\n");
+            next if $bad;
+            my ($o, $txt) = ($1, $2);
+            if ($#cats == -1 && $o eq "+") {
+                &transcript("User defined category specification must start with a category name. Skipping.\n\n");
+               $errors++;
+                $bad = 1;
+                next;
+            }
+            if ($o eq "+") {
+               unless (ref($cats[-1]) eq "HASH") {
+                   $cats[-1] = { "nam" => $cats[-1], 
+                                 "pri" => [], "ttl" => [] };
+               }
+               $catsec++;
+               my ($desc, $ord, $op);
+                if ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?\]\s*$/) {
+                    $desc = $1; $ord = $3; $op = "";
+                } elsif ($txt =~ m/^(.*\S)\s*\[((\d+):\s*)?(\S+)\]\s*$/) {
+                    $desc = $1; $ord = $3; $op = $4;
+                } elsif ($txt =~ m/^([^[\s]+)\s*$/) {
+                    $desc = ""; $op = $1;
+                } else {
+                    &transcript("Unrecognised syntax for category section. Skipping.\n\n");
+                   $errors++;
+                    $bad = 1;
+                    next;
+                }
+               $ord = 999 unless defined $ord;
+
+               if ($op) {
+                    push @{$cats[-1]->{"pri"}}, $prefix . $op;
+                   push @{$cats[-1]->{"ttl"}}, $desc;
+                   push @ords, "$ord $catsec";
+               } else {
+                   @cats[-1]->{"def"} = $desc;
+                   push @ords, "$ord DEF";
+                   $catsec--;
+               }
+               @ords = sort { my ($a1, $a2, $b1, $b2) = split / /, "$a $b";
+                              $a1 <=> $b1 || $a2 <=> $b2; } @ords;
+               $cats[-1]->{"ord"} = [map { m/^.* (\S+)/; $1 eq "DEF" ? $catsec + 1 : $1 } @ords];
+            } elsif ($o eq "*") {
+               $catsec = 0;
+                my ($name);
+                if ($txt =~ m/^(.*\S)(\s*\[(\S+)\])\s*$/) {
+                    $name = $1; $prefix = $3;
+                } else {
+                    $name = $txt; $prefix = "";
+                }
+                push @cats, $name;
+            }
+        }
+        # XXX: got @cats, now do something with it
+       my $u = Debbugs::User::get_user($user);
+       if (@cats) {
+           &transcript("Added usercategory $catname.\n\n");
+           $u->{"categories"}->{$catname} = [ @cats ];
+       } else {
+           &transcript("Removed usercategory $catname.\n\n");
+           delete $u->{"categories"}->{$catname};
+       }
+       $u->write();
+    } elsif (m/^usertags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
+       $ok++;
+       $ref = $1; $addsubcode = $3 || "+"; $tags = $4;
+       if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
+            $ref = $clonebugs{$ref};
+        }
+       if ($user eq "") {
+           &transcript("No valid user selected\n");
+           $errors++;
+        } elsif (&setbug) {
+           &nochangebug;
+           my %ut;
+           Debbugs::User::read_usertags(\%ut, $user);
+            my @oldtags = (); my @newtags = (); my @badtags = ();
+           my %chtags;
+           for my $t (split /[,\s]+/, $tags) {
+               if ($t =~ m/^[a-zA-Z0-9.+\@-]+$/) {
+                   $chtags{$t} = 1;
+               } else {
+                   push @badtags, $t;
+               }
+           }
+           if (@badtags) {
+                &transcript("Ignoring illegal tag/s: ".join(', ', @badtags).".\nPlease use only alphanumerics, at, dot, plus and dash.\n");
+               $errors++;
+           }
+            for my $t (keys %chtags) {
+               $ut{$t} = [] unless defined $ut{$t};
+           }
+           for my $t (keys %ut) {
+               my %res = map { ($_, 1) } @{$ut{$t}};
+               push @oldtags, $t if defined $res{$ref};
+               my $addop = ($addsubcode eq "+" or $addsubcode eq "=");
+               my $del = (defined $chtags{$t} ? $addsubcode eq "-" 
+                                              : $addsubcode eq "=");
+               $res{$ref} = 1 if ($addop && defined $chtags{$t});
+               delete $res{$ref} if ($del);
+               push @newtags, $t if defined $res{$ref};
+               $ut{$t} = [ sort { $a <=> $b } (keys %res) ];
+           }
+           if (@oldtags == 0) {
+               &transcript("There were no usertags set.\n");
+           } else {
+               &transcript("Usertags were: " . join(" ", @oldtags) . ".\n");
+           }
+           &transcript("Usertags are now: " . join(" ", @newtags) . ".\n");
+           Debbugs::User::write_usertags(\%ut, $user);
+       }
     } elsif (!$control) {
         &transcript(<<END);
 Unknown command or malformed arguments to command.
 (Use control\@$gEmailDomain to manipulate reports.)
 
 END
+       $errors++;
         if (++$unknowns >= 3) {
             &transcript("Too many unknown commands, stopping here.\n\n");
             last;
         }
-#### interesting ones start here
-    } elsif (m/^close\s+\#?(-?\d+)$/i) {
+#### "developer only" ones start here
+    } elsif (m/^close\s+\#?(-?\d+)(?:\s+(\d.*))?$/i) {
        $ok++;
        $ref= $1;
+       $bug_affected{$ref}=1;
+       $version= $2;
        if (&setbug) {
            &transcript("'close' is deprecated; see http://$gWebDomain/Developer$gHTMLSuffix#closing.\n");
-           if (length($data->{done})) {
+           if (length($data->{done}) and not defined($version)) {
                &transcript("$gBug is already closed, cannot re-close.\n\n");
                 &nochangebug;
             } else {
-                $action= "$gBug closed, send any further explanations to $data->{originator}";
+                $action= "$gBug " .
+                    (defined($version) ?
+                        "marked as fixed in version $version" :
+                        "closed") .
+                    ", send any further explanations to $data->{originator}";
                 do {
-                    &addmaintainers($data->{package});
+                    &addmaintainers($data);
                                        if ( length( $gDoneList ) > 0 && length( $gListDomain ) >
                                        0 ) { &addccaddress("$gDoneList\@$gListDomain"); }
                     $data->{done}= $replyto;
+                    my @keywords= split ' ', $data->{keywords};
+                    if (grep $_ eq 'pending', @keywords) {
+                        $extramessage= "Removed pending tag.\n";
+                        $data->{keywords}= join ' ', grep $_ ne 'pending',
+                                                @keywords;
+                    }
+                    addfixedversions($data, $data->{package}, $version, 'binary');
+
                    $message= <<END;
 From: $gMaintainerEmail ($gProject $gBug Tracking System)
 To: $data->{originator}
@@ -262,6 +438,7 @@ References: $header{'message-id'} $data->{msgid}
 In-Reply-To: $data->{msgid}
 Message-ID: <handler.$ref.$nn.notifdonectrl.$midix\@$gEmailDomain>
 Reply-To: $ref\@$gEmailDomain
+X-$gProject-PR-Message: they-closed-control $ref
 
 This is an automatic notification regarding your $gBug report
 #$ref: $data->{subject},
@@ -281,9 +458,11 @@ END
                 } while (&getnextbug);
             }
         }
-    } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
+    } elsif (m/^reassign\s+\#?(-?\d+)\s+(\S+)(?:\s+(\d.*))?$/i) {
         $ok++;
         $ref= $1; $newpackage= $2;
+       $bug_affected{$ref}=1;
+        $version= $3;
        $newpackage =~ y/A-Z/a-z/;
         if (&setbug) {
             if (length($data->{package})) {
@@ -293,9 +472,13 @@ END
                 $action= "$gBug assigned to package \`$newpackage'.";
             }
             do {
-                &addmaintainers($data->{package});
-                &addmaintainers($newpackage);
+                &addmaintainers($data);
                 $data->{package}= $newpackage;
+                $data->{found_versions}= [];
+                $data->{fixed_versions}= [];
+                # TODO: what if $newpackage is a source package?
+                addfoundversions($data, $data->{package}, $version, 'binary');
+                &addmaintainers($data);
             } while (&getnextbug);
         }
     } elsif (m/^reopen\s+\#?(-?\d+)$/i ? ($noriginator='', 1) :
@@ -304,7 +487,11 @@ END
              m/^reopen\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($noriginator=$2, 1) : 0) {
         $ok++;
         $ref= $1;
+       $bug_affected{$ref}=1;
         if (&setbug) {
+            if (@{$data->{fixed_versions}}) {
+                &transcript("'reopen' may be inappropriate when a bug has been closed with a version;\nyou may need to use 'found' to remove fixed versions.\n");
+            }
             if (!length($data->{done})) {
                 &transcript("$gBug is already open, cannot reopen.\n\n");
                 &nochangebug;
@@ -313,32 +500,126 @@ END
                     $noriginator eq '' ? "$gBug reopened, originator not changed." :
                         "$gBug reopened, originator set to $noriginator.";
                 do {
-                    &addmaintainers($data->{package});
+                    &addmaintainers($data);
                     $data->{originator}= $noriginator eq '' ?  $data->{originator} : $noriginator;
+                    $data->{fixed_versions}= [];
                     $data->{done}= '';
                 } while (&getnextbug);
             }
         }
-    } elsif (m/^submitter\s+\#?(-?\d+)\s+\!$/i ? ($newsubmitter=$replyto, 1) :
+    } elsif (m{^found\s+\#?(-?\d+)
+              (?:\s+(?:$config{package_name_re}\/)?
+                   ($config{package_version_re}))?$}ix) {
+        $ok++;
+        $ref= $1;
+        $version= $2;
+        if (&setbug) {
+            if (!length($data->{done}) and not defined($version)) {
+                &transcript("$gBug is already open, cannot reopen.\n\n");
+               $errors++;
+                &nochangebug;
+            } else {
+                $action=
+                    defined($version) ?
+                        "$gBug marked as found in version $version." :
+                        "$gBug reopened.";
+                do {
+                    &addmaintainers($data);
+                    # The 'done' field gets a bit weird with version
+                    # tracking, because a bug may be closed by multiple
+                    # people in different branches. Until we have something
+                    # more flexible, we set it every time a bug is fixed,
+                    # and clear it precisely when a found command is
+                    # received for the rightmost fixed-in version, which
+                    # equates to the most recent fixing of the bug, or when
+                    # a versionless found command is received.
+                    if (defined $version) {
+                        my $lastfixed = $data->{fixed_versions}[-1];
+                        # TODO: what if $data->{package} is a source package?
+                        addfoundversions($data, $data->{package}, $version, 'binary');
+                        if (defined $lastfixed and not grep { $_ eq $lastfixed } @{$data->{fixed_versions}}) {
+                            $data->{done} = '';
+                        }
+                    } else {
+                        # Versionless found; assume old-style "not fixed at
+                        # all".
+                        $data->{fixed_versions} = [];
+                        $data->{done} = '';
+                    }
+                } while (&getnextbug);
+            }
+        }
+    } elsif (m/^notfound\s+\#?(-?\d+)\s+(\d.*)$/i) {
+        $ok++;
+        $ref= $1;
+        $version= $2;
+        if (&setbug) {
+            $action= "$gBug marked as not found in version $version.";
+            if (length($data->{done})) {
+                $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
+            }
+            do {
+                &addmaintainers($data);
+                removefoundversions($data, $data->{package}, $version, 'binary');
+            } while (&getnextbug);
+       }
+   }
+    elsif (m[^fixed\s+\#?(-?\d+)\s+
+            ((?:$config{package_name_re}\/)?
+                 $config{package_version_re})\s*$]ix) {
+        $ok++;
+        $ref= $1;
+        $version= $2;
+        if (&setbug) {
+            $action=
+                 defined($version) ?
+                      "$gBug marked as fixed in version $version." :
+                           "$gBug reopened.";
+                do {
+                    &addmaintainers($data);
+                    addfixedversions($data, $data->{package}, $version, 'binary');
+              } while (&getnextbug);
+       }
+   }
+    elsif (m[^notfixed\s+\#?(-?\d+)\s+
+            ((?:$config{package_name_re}\/)?
+                 $config{package_version_re})\s*$]ix) {
+        $ok++;
+        $ref= $1;
+        $version= $2;
+        if (&setbug) {
+            $action=
+                 defined($version) ?
+                      "$gBug marked as not fixed in version $version." :
+                           "$gBug reopened.";
+                do {
+                    &addmaintainers($data);
+                    removefixedversions($data, $data->{package}, $version, 'binary');
+              } while (&getnextbug);
+       }
+   }
+    elsif (m/^submitter\s+\#?(-?\d+)\s+\!$/i ? ($newsubmitter=$replyto, 1) :
              m/^submitter\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newsubmitter=$2, 1) : 0) {
         $ok++;
         $ref= $1;
+       $bug_affected{$ref}=1;
         if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
             $ref = $clonebugs{$ref};
         }
         if (&getbug) {
-            &foundbug;
-            &addmaintainers($data->{package});
-            $oldsubmitter= $data->{originator};
-            $data->{originator}= $newsubmitter;
-            $action= "Changed $gBug submitter from $oldsubmitter to $newsubmitter.";
-            &savebug;
-            &transcript("$action\n");
-            if (length($data->{done})) {
-                &transcript("(By the way, that $gBug is currently marked as done.)\n");
-            }
-            &transcript("\n");
-            $message= <<END;
+            if (&checkpkglimit) {
+                &foundbug;
+                &addmaintainers($data);
+                $oldsubmitter= $data->{originator};
+                $data->{originator}= $newsubmitter;
+                $action= "Changed $gBug submitter from $oldsubmitter to $newsubmitter.";
+                &savebug;
+                &transcript("$action\n");
+                if (length($data->{done})) {
+                    &transcript("(By the way, that $gBug is currently marked as done.)\n");
+                }
+                &transcript("\n");
+                $message= <<END;
 From: $gMaintainerEmail ($gProject $gBug Tracking System)
 To: $oldsubmitter
 Subject: $gBug#$ref submitter address changed
@@ -347,12 +628,15 @@ References: $header{'message-id'} $data->{msgid}
 In-Reply-To: $data->{msgid}
 Message-ID: <handler.$ref.$nn.newsubmitter.$midix\@$gEmailDomain>
 Reply-To: $ref\@$gEmailDomain
+X-$gProject-PR-Message: submitter-changed $ref
 
 The submitter address recorded for your $gBug report
 #$ref: $data->{subject}
 has been changed.
 
-The new submitter address for this report is
+The old submitter address for this report was
+$oldsubmitter.
+The new submitter address is
 $newsubmitter.
 
 This change was made by
@@ -363,13 +647,17 @@ $gMaintainer
 (administrator, $gProject $gBugs database)
 
 END
-            &sendmailmessage($message,$oldsubmitter);
+                &sendmailmessage($message,$oldsubmitter);
+            } else {
+                &cancelbug;
+            }
         } else {
             &notfoundbug;
         }
     } elsif (m/^forwarded\s+\#?(-?\d+)\s+(\S.*\S)$/i) {
         $ok++;
         $ref= $1; $whereto= $2;
+       $bug_affected{$ref}=1;
         if (&setbug) {
             if (length($data->{forwarded})) {
     $action= "Forwarded-to-address changed from $data->{forwarded} to $whereto.";
@@ -380,9 +668,9 @@ END
                 $extramessage= "(By the way, this $gBug is currently marked as done.)\n";
             }
             do {
-                &addmaintainers($data->{package});
-               if (length($gFowardList)>0 && length($gListDomain)>0 ) {
-                    &addccaddress("$gFowardList\@$gListDomain"); 
+                &addmaintainers($data);
+               if (length($gForwardList)>0 && length($gListDomain)>0 ) {
+                    &addccaddress("$gForwardList\@$gListDomain"); 
                }
                 $data->{forwarded}= $whereto;
             } while (&getnextbug);
@@ -390,6 +678,7 @@ END
     } elsif (m/^notforwarded\s+\#?(-?\d+)$/i) {
         $ok++;
         $ref= $1;
+       $bug_affected{$ref}=1;
         if (&setbug) {
             if (!length($data->{forwarded})) {
                 &transcript("$gBug is not marked as having been forwarded.\n\n");
@@ -397,7 +686,7 @@ END
             } else {
     $action= "Removed annotation that $gBug had been forwarded to $data->{forwarded}.";
                 do {
-                    &addmaintainers($data->{package});
+                    &addmaintainers($data);
                     $data->{forwarded}= '';
                 } while (&getnextbug);
             }
@@ -406,25 +695,32 @@ END
        m/^priority\s+\#?(-?\d+)\s+([-0-9a-z]+)$/i) {
         $ok++;
         $ref= $1;
+       $bug_affected{$ref}=1;
         $newseverity= $2;
         if (!grep($_ eq $newseverity, @gSeverityList, "$gDefaultSeverity")) {
             &transcript("Severity level \`$newseverity' is not known.\n".
                        "Recognized are: $gShowSeverities.\n\n");
+           $errors++;
         } elsif (exists $gObsoleteSeverities{$newseverity}) {
             &transcript("Severity level \`$newseverity' is obsolete. " .
-                        "$gObsoleteSeverities{$newseverity}\n\n");
+                        "Use $gObsoleteSeverities{$newseverity} instead.\n\n");
+               $errors++;
         } elsif (&setbug) {
             $printseverity= $data->{severity};
             $printseverity= "$gDefaultSeverity" if $printseverity eq '';
-           $action= "Severity set to \`$newseverity'.";
+           $action= "Severity set to \`$newseverity' from \`$printseverity'";
            do {
-                &addmaintainers($data->{package});
+                &addmaintainers($data);
+                if (defined $gStrongList and isstrongseverity($newseverity)) {
+                    addbcc("$gStrongList\@$gListDomain");
+                }
                 $data->{severity}= $newseverity;
             } while (&getnextbug);
         }
     } elsif (m/^tags?\s+\#?(-?\d+)\s+(([=+-])\s*)?(\S.*)?$/i) {
        $ok++;
        $ref = $1; $addsubcode = $3; $tags = $4;
+       $bug_affected{$ref}=1;
        $addsub = "add";
        if (defined $addsubcode) {
            $addsub = "sub" if ($addsubcode eq "-");
@@ -443,6 +739,7 @@ END
        if (@badtags) {
             &transcript("Unknown tag/s: ".join(', ', @badtags).".\n".
                        "Recognized are: ".join(' ', @gTags).".\n\n");
+           $errors++;
        }
        if (&setbug) {
            if ($data->{keywords} eq '') {
@@ -458,14 +755,16 @@ END
                $action= "Tags removed: " . join(", ", @okaytags);
            }
            do {
-                &addmaintainers($data->{package});
+                &addmaintainers($data);
                $data->{keywords} = '' if ($addsub eq "set");
+               # Allow removing obsolete tags.
                if ($addsub eq "sub") {
                    foreach my $t (@badtags) {
                        $data->{keywords} = join ' ', grep $_ ne $t, 
                            split ' ', $data->{keywords};
                    }
                }
+               # Now process all other additions and subtractions.
                foreach my $t (@okaytags) {
                    $data->{keywords} = join ' ', grep $_ ne $t, 
                        split ' ', $data->{keywords};
@@ -474,29 +773,140 @@ END
                $data->{keywords} =~ s/\s*$//;
             } while (&getnextbug);
        }
+    } elsif (m/^(un)?block\s+\#?(-?\d+)\s+(by|with)\s+\s*(\S.*)?$/i) {
+       $ok++;
+       my $bugnum = $2; my $blockers = $4;
+       $addsub = "add";
+       $addsub = "sub" if ($1 eq "un");
+       if ($bugnum =~ m/^-\d+$/ && defined $clonebugs{$bugnum}) {
+            $bugnum = $clonebugs{$bugnum};
+       }
+
+       my @okayblockers;
+       my @badblockers;
+       foreach my $b (split /[\s,]+/, $blockers) {
+           $b=~s/^\#//;
+           if ($b=~/[0-9]+/) {
+               $ref=$b;
+               if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
+                    $ref = $clonebugs{$ref};
+               }
+               if (&getbug) {
+                   &foundbug;
+                   push @okayblockers, $ref;
+
+                   # add to the list all bugs that are merged with $b,
+                   # because all of their data must be kept in sync
+                   @thisbugmergelist= split(/ /,$data->{mergedwith});
+                   &cancelbug;
+
+                   foreach $ref (@thisbugmergelist) {
+                       if (&getbug) {
+                          push @okayblockers, $ref;
+                          &cancelbug;
+                       }
+                   }
+               }
+               else {
+                   &notfoundbug;
+                    push @badblockers, $ref;
+               }
+           }
+           else {
+                push @badblockers, $b;
+           }
+       }
+       if (@badblockers) {
+            &transcript("Unknown blocking bug/s: ".join(', ', @badblockers).".\n");
+           $errors++;
+       }
+       
+       $ref=$bugnum;
+       if (&setbug) {
+           if ($data->{blockedby} eq '') {
+               &transcript("Was not blocked by any bugs.\n");
+           } else {
+               &transcript("Was blocked by: $data->{blockedby}\n");
+           }
+           if ($addsub eq "set") {
+               $action= "Blocking bugs of $bugnum set to: " . join(", ", @okayblockers);
+           } elsif ($addsub eq "add") {
+               $action= "Blocking bugs of $bugnum added: " . join(", ", @okayblockers);
+           } elsif ($addsub eq "sub") {
+               $action= "Blocking bugs of $bugnum removed: " . join(", ", @okayblockers);
+           }
+           my %removedblocks;
+           my %addedblocks;
+           do {
+                &addmaintainers($data);
+               my @oldblockerlist = split ' ', $data->{blockedby};
+               $data->{blockedby} = '' if ($addsub eq "set");
+               foreach my $b (@okayblockers) {
+                       $data->{blockedby} = manipset($data->{blockedby}, $b,
+                               ($addsub ne "sub"));
+               }
+
+               foreach my $b (@oldblockerlist) {
+                       if (! grep { $_ eq $b } split ' ', $data->{blockedby}) {
+                               push @{$removedblocks{$b}}, $ref;
+                       }
+               }
+               foreach my $b (split ' ', $data->{blockedby}) {
+                       if (! grep { $_ eq $b } @oldblockerlist) {
+                               push @{$addedblocks{$b}}, $ref;
+                       }
+               }
+            } while (&getnextbug);
+
+           # Now that the blockedby data is updated, change blocks data
+           # to match the changes.
+           foreach $ref (keys %addedblocks) {
+               if (&getbug) {
+                   foreach my $b (@{$addedblocks{$ref}}) {
+                       $data->{blocks} = manipset($data->{blocks}, $b, 1);
+                   }
+                   &savebug;
+                }
+           }
+           foreach $ref (keys %removedblocks) {
+               if (&getbug) {
+                   foreach my $b (@{$removedblocks{$ref}}) {
+                       $data->{blocks} = manipset($data->{blocks}, $b, 0);
+                   }
+                   &savebug;
+                }
+           }
+       }
     } elsif (m/^retitle\s+\#?(-?\d+)\s+(\S.*\S)\s*$/i) {
         $ok++;
         $ref= $1; $newtitle= $2;
+       $bug_affected{$ref}=1;
        if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
            $ref = $clonebugs{$ref};
        }
         if (&getbug) {
-            &foundbug;
-            &addmaintainers($data->{package});
-            $data->{subject}= $newtitle;
-            $action= "Changed $gBug title.";
-            &savebug;
-            &transcript("$action\n");
-            if (length($data->{done})) {
-                &transcript("(By the way, that $gBug is currently marked as done.)\n");
+            if (&checkpkglimit) {
+                &foundbug;
+                &addmaintainers($data);
+               my $oldtitle = $data->{subject};
+                $data->{subject}= $newtitle;
+                $action= "Changed $gBug title to $newtitle from $oldtitle.";
+                &savebug;
+                &transcript("$action\n");
+                if (length($data->{done})) {
+                    &transcript("(By the way, that $gBug is currently marked as done.)\n");
+                }
+                &transcript("\n");
+            } else {
+                &cancelbug;
             }
-            &transcript("\n");
         } else {
             &notfoundbug;
         }
     } elsif (m/^unmerge\s+\#?(-?\d+)$/i) {
        $ok++;
        $ref= $1;
+       $bug_affected{$ref} = 1;
        if (&setbug) {
            if (!length($data->{mergedwith})) {
                &transcript("$gBug is not marked as being merged with any others.\n\n");
@@ -506,18 +916,21 @@ END
                $action= "Disconnected #$ref from all other report(s).";
                @newmergelist= split(/ /,$data->{mergedwith});
                 $discref= $ref;
+               @bug_affected{@newmergelist} = 1 x @newmergelist;
                 do {
-                    &addmaintainers($data->{package});
+                    &addmaintainers($data);
                    $data->{mergedwith}= ($ref == $discref) ? ''
                         : join(' ',grep($_ ne $ref,@newmergelist));
                 } while (&getnextbug);
            }
        }
-    } elsif (m/^merge\s+(-?\d+(\s+-?\d+)+)\s*$/i) {
+    } elsif (m/^merge\s+#?(-?\d+(\s+#?-?\d+)+)\s*$/i) {
        $ok++;
-        @tomerge= sort { $a <=> $b } split(/\s+/,$1);
-        @newmergelist= ();
+        my @tomerge= sort { $a <=> $b } split(/\s+#?/,$1);
+        my @newmergelist= ();
        my %tags = ();
+       my %found = ();
+       my %fixed = ();
         &getmerge;
         while (defined($ref= shift(@tomerge))) {
             &transcript("D| checking merge $ref\n") if $dl;
@@ -525,20 +938,27 @@ END
            if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
                $ref = $clonebugs{$ref};
            }
-           next if grep($_ eq $ref,@newmergelist);
+           next if grep($_ == $ref,@newmergelist);
            if (!&getbug) { &notfoundbug; @newmergelist=(); last }
+            if (!&checkpkglimit) { &cancelbug; @newmergelist=(); last; }
             &foundbug;
             &transcript("D| adding $ref ($data->{mergedwith})\n") if $dl;
            $mismatch= '';
-           &checkmatch('package','m_package',$data->{package});
-           &checkmatch('forwarded addr','m_forwarded',$data->{forwarded});
+           &checkmatch('package','m_package',$data->{package},@newmergelist);
+           &checkmatch('forwarded addr','m_forwarded',$data->{forwarded},@newmergelist);
            $data->{severity} = '$gDefaultSeverity' if $data->{severity} eq '';
-           &checkmatch('severity','m_severity',$data->{severity});
-           &checkmatch('done mark','m_done',length($data->{done}) ? 'done' : 'open');
+           &checkmatch('severity','m_severity',$data->{severity},@newmergelist);
+           &checkmatch('blocks','m_blocks',$data->{blocks},@newmergelist);
+           &checkmatch('blocked-by','m_blockedby',$data->{blockedby},@newmergelist);
+           &checkmatch('done mark','m_done',length($data->{done}) ? 'done' : 'open',@newmergelist);
+           &checkmatch('owner','m_owner',$data->{owner},@newmergelist);
            foreach my $t (split /\s+/, $data->{keywords}) { $tags{$t} = 1; }
+           foreach my $f (@{$data->{found_versions}}) { $found{$f} = 1; }
+           foreach my $f (@{$data->{fixed_versions}}) { $fixed{$f} = 1; }
            if (length($mismatch)) {
                &transcript("Mismatch - only $gBugs in same state can be merged:\n".
                             $mismatch."\n");
+               $errors++;
                &cancelbug; @newmergelist=(); last;
            }
             push(@newmergelist,$ref);
@@ -548,11 +968,78 @@ END
        if (@newmergelist) {
             @newmergelist= sort { $a <=> $b } @newmergelist;
             $action= "Merged @newmergelist.";
+           delete @fixed{keys %found};
+           for $ref (@newmergelist) {
+               &getbug || die "huh ?  $gBug $ref disappeared during merge";
+                &addmaintainers($data);
+               @bug_affected{@newmergelist} = 1 x @newmergelist;
+               $data->{mergedwith}= join(' ',grep($_ != $ref,@newmergelist));
+               $data->{keywords}= join(' ', keys %tags);
+               $data->{found_versions}= [sort keys %found];
+               $data->{fixed_versions}= [sort keys %fixed];
+               &savebug;
+           }
+           &transcript("$action\n\n");
+       }
+        &endmerge;
+    } elsif (m/^forcemerge\s+\#?(-?\d+(?:\s+\#?-?\d+)+)\s*$/i) {
+       $ok++;
+       my @temp = split /\s+\#?/,$1;
+       my $master_bug = shift @temp;
+       my $master_bug_data;
+       my @tomerge = sort { $a <=> $b } @temp;
+        unshift @tomerge,$master_bug;
+       &transcript("D| force merging ".join(',',@tomerge)."\n") if $dl;
+       my @newmergelist= ();
+       my %tags = ();
+       my %found = ();
+       my %fixed = ();
+       # Here we try to do the right thing.
+       # First, if the bugs are in the same package, we merge all of the found, fixed, and tags.
+       # If not, we discard the found and fixed.
+       # Everything else we set to the values of the first bug.
+        &getmerge;
+        while (defined($ref= shift(@tomerge))) {
+            &transcript("D| checking merge $ref\n") if $dl;
+           $ref+= 0;
+           if ($ref =~ m/^-\d+$/ && defined $clonebugs{$ref}) {
+               $ref = $clonebugs{$ref};
+           }
+           next if grep($_ == $ref,@newmergelist);
+           if (!&getbug) { &notfoundbug; @newmergelist=(); last }
+            if (!&checkpkglimit) { &cancelbug; @newmergelist=(); last; }
+            &foundbug;
+            &transcript("D| adding $ref ($data->{mergedwith})\n") if $dl;
+           $master_bug_data = $data if not defined $master_bug_data;
+           if ($data->{package} ne $master_bug_data->{package}) {
+               &transcript("Mismatch - only $gBugs in the same package can be forcibly merged:\n".
+                           "$gBug $ref is not in the same package as $master_bug\n");
+               $errors++;
+               &cancelbug; @newmergelist=(); last;
+           }
+           for my $t (split /\s+/,$data->{keywords}) {
+                $tags{$t} = 1;
+           }
+           @found{@{$data->{found_versions}}} = (1) x @{$data->{found_versions}};
+           @fixed{@{$data->{fixed_versions}}} = (1) x @{$data->{fixed_versions}};
+           push(@newmergelist,$ref);
+            push(@tomerge,split(/ /,$data->{mergedwith}));
+           &cancelbug;
+       }
+       if (@newmergelist) {
+            @newmergelist= sort { $a <=> $b } @newmergelist;
+            $action= "Forcibly Merged @newmergelist.";
+           delete @fixed{keys %found};
            for $ref (@newmergelist) {
                &getbug || die "huh ?  $gBug $ref disappeared during merge";
-                &addmaintainers($data->{package});
-               $data->{mergedwith}= join(' ',grep($_ ne $ref,@newmergelist));
+                &addmaintainers($data);
+               @bug_affected{@newmergelist} = 1 x @newmergelist;
+               $data->{mergedwith}= join(' ',grep($_ != $ref,@newmergelist));
                $data->{keywords}= join(' ', keys %tags);
+               $data->{found_versions}= [sort keys %found];
+               $data->{fixed_versions}= [sort keys %fixed];
+               my @field_list = qw(forwarded package severity blocks blockedby owner done);
+               @{$data}{@field_list} = @{$master_bug_data}{@field_list};
                &savebug;
            }
            &transcript("$action\n\n");
@@ -566,9 +1053,11 @@ END
        $newbugsneeded = scalar(@newclonedids);
 
        $ref = $origref;
+       $bug_affected{$ref} = 1;
        if (&setbug) {
            if (length($data->{mergedwith})) {
-               &transcript("$gBug is marked as being merged with others.\n\n");
+               &transcript("$gBug is marked as being merged with others. Use an existing clone.\n\n");
+               $errors++;
                &nochangebug;
            } else {
                &filelock("nextnumber.lock");
@@ -585,23 +1074,42 @@ END
                } else {
                    $action= "$gBug $origref cloned as bugs $firstref-$lastref.";
                }
+
+               my $blocks = $data->{blocks};
+               my $blockedby = $data->{blockedby};
+               
                &getnextbug;
                my $ohash = get_hashname($origref);
-               $ref = $firstref;
+               my $clone = $firstref;
+                @bug_affected{@newclonedids} = 1 x @newclonedids;
                for $newclonedid (@newclonedids) {
-                   $clonebugs{$newclonedid} = $ref;
+                   $clonebugs{$newclonedid} = $clone;
            
-                   my $hash = get_hashname($ref);
-                   copy("db-h/$ohash/$origref.log", "db-h/$hash/$ref.log");
-                   copy("db-h/$ohash/$origref.status", "db-h/$hash/$ref.status");
-                   copy("db-h/$ohash/$origref.report", "db-h/$hash/$ref.report");
-                   &bughook('new', $ref, "$data->{originator}\n$data->{date}\n$data->{subject}\n$data->{msgid}\n$data->{package}\n$data->{keywords}\n$data->{done}\n$data->{forwarded}\n$data->{mergedwith}\n$data->{severity}\n");
+                   my $hash = get_hashname($clone);
+                   copy("db-h/$ohash/$origref.log", "db-h/$hash/$clone.log");
+                   copy("db-h/$ohash/$origref.status", "db-h/$hash/$clone.status");
+                   copy("db-h/$ohash/$origref.summary", "db-h/$hash/$clone.summary");
+                   copy("db-h/$ohash/$origref.report", "db-h/$hash/$clone.report");
+                   &bughook('new', $clone, $data);
+               
+                   # Update blocking info of bugs blocked by or blocking the
+                   # cloned bug.
+                   foreach $ref (split ' ', $blocks) {
+                       &getbug;
+                       $data->{blockedby} = manipset($data->{blockedby}, $clone, 1);
+                       &savebug;
+                   }
+                   foreach $ref (split ' ', $blockedby) {
+                       &getbug;
+                       $data->{blocks} = manipset($data->{blocks}, $clone, 1);
+                       &savebug;
+                   }
 
-                   $ref++;
+                   $clone++;
                }
            }
        }
-    } elsif (m/^package\s*(\S.*\S)?\s*$/i) {
+    } elsif (m/^package\:?\s+(\S.*\S)?\s*$/i) {
         $ok++;
        my @pkgs = split /\s+/, $1;
        if (scalar(@pkgs) > 0) {
@@ -612,8 +1120,46 @@ END
                %limit_pkgs = ();
                &transcript("Not ignoring any bugs.\n\n");
        }
+    } elsif (m/^owner\s+\#?(-?\d+)\s+!$/i ? ($newowner = $replyto, 1) :
+             m/^owner\s+\#?(-?\d+)\s+(\S.*\S)$/i ? ($newowner = $2, 1) : 0) {
+        $ok++;
+        $ref = $1;
+       $bug_affected{$ref} = 1;
+        if (&setbug) {
+            if (length $data->{owner}) {
+                $action = "Owner changed from $data->{owner} to $newowner.";
+            } else {
+                $action = "Owner recorded as $newowner.";
+            }
+            if (length $data->{done}) {
+                $extramessage = "(By the way, this $gBug is currently " .
+                                "marked as done.)\n";
+            }
+            do {
+                &addmaintainers($data);
+                $data->{owner} = $newowner;
+            } while (&getnextbug);
+        }
+    } elsif (m/^noowner\s+\#?(-?\d+)$/i) {
+        $ok++;
+        $ref = $1;
+       $bug_affected{$ref} = 1;
+        if (&setbug) {
+            if (length $data->{owner}) {
+                $action = "Removed annotation that $gBug was owned by " .
+                          "$data->{owner}.";
+                do {
+                    &addmaintainers($data);
+                    $data->{owner} = '';
+                } while (&getnextbug);
+            } else {
+                &transcript("$gBug is not marked as having an owner.\n\n");
+                &nochangebug;
+            }
+        }
     } else {
         &transcript("Unknown command or malformed arguments to command.\n\n");
+       $errors++;
         if (++$unknowns >= 5) {
             &transcript("Too many unknown commands, stopping here.\n\n");
             last;
@@ -624,6 +1170,7 @@ if ($procline>$#bodylines) {
     &transcript(">\nEnd of message, stopping processing here.\n\n");
 }
 if (!$ok && !quickabort) {
+    $errors++;
     &transcript("No commands successfully parsed; sending the help text(s).\n");
     &sendhelp;
     &transcript("\n");
@@ -657,18 +1204,25 @@ if (@maintccs) {
     $maintccs .= "Cc: " . join(",\n    ",@maintccs) . "\n";
 }
 
+# Add Bcc's to subscribed bugs
+push @bcc, map {"bugs=$_\@$gListDomain"} keys %bug_affected;
+
 if (!defined $header{'subject'} || $header{'subject'} eq "") {
   $header{'subject'} = "your mail";
 }
 
+# Error text here advertises how many errors there were
+my $error_text = $errors > 0 ? " (with $errors errors)":'';
+
 $reply= <<END;
 From: $gMaintainerEmail ($gProject $gBug Tracking System)
 To: $replyto
-${maintccs}Subject: Processed: $header{'subject'}
+${maintccs}Subject: Processed${error_text}: $header{'subject'}
 In-Reply-To: $header{'message-id'}
 References: $header{'message-id'}
 Message-ID: <handler.s.$nn.transcript\@$gEmailDomain>
 Precedence: bulk
+X-$gProject-PR-Message: transcript
 
 ${transcript}Please contact me if you need assistance.
 
@@ -684,30 +1238,24 @@ print(AP
       "\2\n$repliedshow\n\5\n$reply\n\3\n".
       "\6\n".
       "<strong>Request received</strong> from <code>".
-      &sani($header{'from'})."</code>\n".
-      "to <code>".&sani($controlrequestaddr)."</code>\n".
+      html_escape($header{'from'})."</code>\n".
+      "to <code>".html_escape($controlrequestaddr)."</code>\n".
       "\3\n".
       "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/-1.log: $!");
 close(AP) || &quit("open db-h/-1.log: $!");
 &unfilelock;
 utime(time,time,"db-h");
 
-&sendmailmessage($reply,$replyto,@maintccaddrs,@bcc);
+&sendmailmessage($reply,exists $header{'x-debbugs-no-ack'}?():$replyto,@maintccaddrs,@bcc);
 
 unlink("incoming/P$nn") || &quit("unlinking incoming/P$nn: $!");
 
 sub sendmailmessage {
     local ($message,@recips) = @_;
     $message = "X-Loop: $gMaintainerEmail\n" . $message;
-    print "mailing to >@recips<\n" if $debug;
-    $c= open(D,"|-");
-    defined($c) || &quit("mailing forking for sendmail: $!");
-    if (!$c) { # ie, we are the child process
-        exec '/usr/lib/sendmail','-f'."$gMaintainerEmail",'-odb','-oem','-oi',get_addresses(@recips);
-        die $!;
-    }
-    print(D $message) || &quit("writing to sendmail process: $!");
-    $!=0; close(D); $? && &quit("sendmail gave exit status $? ($!)");
+    send_mail_message(message    => $message,
+                     recipients => \@recips,
+                    );
     $midix++;
 }
 
@@ -722,7 +1270,7 @@ sub sendhelp {
 #}
 
 sub checkmatch {
-    local ($string,$mvarname,$svarvalue) = @_;
+    local ($string,$mvarname,$svarvalue,@newmergelist) = @_;
     local ($mvarvalue);
     if (@newmergelist) {
         eval "\$mvarvalue= \$$mvarname";
@@ -740,6 +1288,30 @@ sub checkmatch {
     }
 }
 
+sub checkpkglimit {
+    if (keys %limit_pkgs and not defined $limit_pkgs{$data->{package}}) {
+        &transcript("$gBug number $ref belongs to package $data->{package}, skipping.\n\n");
+        $errors++;
+        return 0;
+    }
+    return 1;
+}
+
+sub manipset {
+    my $list = shift;
+    my $elt = shift;
+    my $add = shift;
+
+    my %h = map { $_ => 1 } split ' ', $list;
+    if ($add) {
+        $h{$elt}=1;
+    }
+    else {
+       delete $h{$elt};
+    }
+    return join ' ', sort keys %h;
+}
+
 # High-level bug manipulation calls
 # Do announcements themselves
 #
@@ -782,11 +1354,10 @@ sub setbug {
         return 0;
     }
 
-    if (keys %limit_pkgs && not defined $limit_pkgs{$data->{package}}) {
-       &transcript("$gBug number $ref belongs to package $data->{package}, skipping.\n\n");
-       &cancelbug;
-       return 0;
-    } 
+    if (!&checkpkglimit) {
+        &cancelbug;
+        return 0;
+    }
 
     @thisbugmergelist= split(/ /,$data->{mergedwith});
     if (!@thisbugmergelist) {
@@ -849,7 +1420,7 @@ sub getnextbug {
 #    &transcript("$action\n\n")
 #    endmerge
 
-sub notfoundbug { &transcript("$gBug number $ref not found.\n\n"); }
+sub notfoundbug { &transcript("$gBug number $ref not found. (Is it archived?)\n\n"); }
 sub foundbug { &transcript("$gBug#$ref: $data->{subject}\n"); }
 
 sub getmerge {
@@ -900,9 +1471,10 @@ sub savebug {
     open(L,">>db-h/$hash/$ref.log") || &quit("opening db-h/$hash/$ref.log: $!");
     print(L
           "\6\n".
-          "<strong>".&sani($action)."</strong>\n".
-          "Request was from <code>".&sani($header{'from'})."</code>\n".
-          "to <code>".&sani($controlrequestaddr)."</code>. \n".
+         "<!-- time:".time." -->\n".
+          "<strong>".html_escape($action)."</strong>\n".
+          "Request was from <code>".html_escape($header{'from'})."</code>\n".
+          "to <code>".html_escape($controlrequestaddr)."</code>. \n".
           "\3\n".
           "\7\n",@{escapelog(@log)},"\n\3\n") || &quit("writing db-h/$hash/$ref.log: $!");
     close(L) || &quit("closing db-h/$hash/$ref.log: $!");
@@ -962,6 +1534,7 @@ References: $header{'message-id'}
 In-Reply-To: $header{'message-id'}
 Message-ID: <handler.s.$nn.help.$midix\@$gEmailDomain>
 Precedence: bulk
+X-$gProject-PR-Message: doc-text $relpath
 
 END
     $ok++;
@@ -989,6 +1562,7 @@ References: $header{'message-id'}
 In-Reply-To: $header{'message-id'}
 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
 Precedence: bulk
+X-$gProject-PR-Message: doc-html $relpath
 
 END
          $ok++;
@@ -1003,19 +1577,26 @@ sub addccaddress {
 sub addmaintainers {
     # Data structure is:
     #   maintainer email address &c -> assoc of packages -> assoc of bug#'s
-    my ($p, $addmaint, $pshow);
+    my $data = shift;
+    my ($p, $addmaint);
     &ensuremaintainersloaded;
     $anymaintfound=0; $anymaintnotfound=0;
-    for $p (split(m/[ \t?,()]+/,$_[0])) {
+    for $p (split(m/[ \t?,():]+/, $data->{package})) {
        $p =~ y/A-Z/a-z/;
-        $pshow= ($p =~ m/[-+.a-z0-9]+/ ? $& : '');
+       $p =~ /([a-z0-9.+-]+)/;
+       $p = $1;
+       next unless defined $p;
        if (defined $gSubscriptionDomain) {
            if (defined($pkgsrc{$p})) {
-               push @bcc, "$pkgsrc{$p}\@$gSubscriptionDomain";
+               addbcc("$pkgsrc{$p}\@$gSubscriptionDomain");
            } else {
-               push @bcc, "$p\@$gSubscriptionDomain";
+               addbcc("$p\@$gSubscriptionDomain");
            }
        }
+        if (defined $data->{severity} and defined $gStrongList and
+                isstrongseverity($data->{severity})) {
+            addbcc("$gStrongList\@$gListDomain");
+        }
         if (defined($maintainerof{$p})) {
            $addmaint= $maintainerof{$p};
            &transcript("MR|$addmaint|$p|$ref|\n") if $dl>2;
@@ -1028,6 +1609,13 @@ sub addmaintainers {
             $maintccreasons{$gUnknownMaintainerEmail}{$p}{$ref}= 1;
        }
     }
+
+    if (length $data->{owner}) {
+        $addmaint = $data->{owner};
+        &transcript("MO|$addmaint|$data->{package}|$ref|\n") if $dl>2;
+        $maintccreasons{$addmaint}{$data->{package}}{$ref} = 1;
+        print "owner add >$data->{package}|$addmaint<\n" if $debug;
+    }
 }
 
 sub ensuremaintainersloaded {
@@ -1039,7 +1627,7 @@ sub ensuremaintainersloaded {
        m/^\s*$/ && next;
         m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers bogus \`$_'");
         $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
-        $maintainerof{$1}= $2;
+        $maintainerof{$a}= $2;
     }
     close(MAINT);
     open(MAINT,"$gMaintainerFileOverride") || die &quit("maintainers.override open: $!");
@@ -1048,7 +1636,7 @@ sub ensuremaintainersloaded {
         m/^\s*$/ && next;
         m/^(\S+)\s+(\S.*\S)\s*\n$/ || &quit("maintainers.override bogus \`$_'");
         $a= $1; $b= $2; $a =~ y/A-Z/a-z/;
-        $maintainerof{$1}= $2;
+        $maintainerof{$a}= $2;
     }
 
     open(SOURCES, "$gPackageSource") || &quit("pkgsrc open: $!");
@@ -1089,6 +1677,7 @@ References: $header{'message-id'}
 In-Reply-To: $header{'message-id'}
 Message-ID: <handler.s.$nn.info.$midix\@$gEmailDomain>
 Precedence: bulk
+X-$gProject-PR-Message: getinfo
 
 $description follows: