]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/process
Strip BOM before regexes involving spaces (closes: #488554)
[debbugs.git] / scripts / process
index 197ae8d4cfe54e2534742dbfca0896bfc806140c..1bcc940f98a5117e386ecce7f78a4070d58efcf3 100755 (executable)
@@ -28,6 +28,8 @@ use Debbugs::Text qw(:templates);
 use Debbugs::Status qw(:versions);
 use Debbugs::Config qw(:globals :config);
 
+use Debbugs::Control qw(append_action_to_log);
+
 chdir( "$gSpoolDir" ) || die "chdir spool: $!\n";
 
 #open(DEBUG,"> /tmp/debbugs.debug");
@@ -168,6 +170,9 @@ my %pheader;
 # extract pseudo-headers
 for my $phline (@bodylines)
 {
+    # Remove BOM markers from UTF-8 strings
+    # Fixes #488554
+    $phline =~ s/\xef\xbb\xbf//g;
     last if $phline !~ m/^([\w-]+):\s*(\S.*)/;
     my ($fn, $fv) = ($1, $2);
     $fv =~ s/\s*$//;
@@ -223,7 +228,6 @@ if ($tryref >= 0)
     if ($bfound) { 
         $ref= $tryref; 
     } else {
-        &htmllog("Reply","sent", $replyto,"Unknown problem report number <code>$tryref</code>.");
         &sendmessage(create_mime_message(
           [From          => "$gMaintainerEmail ($gProject $gBug Tracking System)",
           To            => $replyto,
@@ -315,7 +319,6 @@ if ($codeletter eq 'D' || $codeletter eq 'F')
        push @generalcc,"$gStrongList\@$gListDomain";
     }
     if ($ref<0) {
-       &htmllog("Warning","sent",$replyto,"Message ignored.");
        &sendmessage(create_mime_message(
           [From          => "$gMaintainerEmail ($gProject $gBug Tracking System)",
           To            => $replyto,
@@ -472,7 +475,6 @@ if ($codeletter eq 'D' || $codeletter eq 'F')
 
 if ($ref<0) { # new bug report
     if ($codeletter eq 'U') { # -submitter
-        &htmllog("Warning","sent",$replyto,"Message not forwarded.");
        &sendmessage(create_mime_message(
           [From          => "$gMaintainerEmail ($gProject $gBug Tracking System)",
           To            => $replyto,
@@ -505,7 +507,6 @@ if ($ref<0) { # new bug report
        $data->{package} = $config{default_package},
     }
     else {
-       &htmllog("Warning","sent",$replyto,"Message not forwarded.");
        my $body = message_body_template('mail/process_no_package',
                                        );
         &sendmessage(create_mime_message(
@@ -916,16 +917,14 @@ die "wot no exit";
 
 sub htmllog {
     my ($whatobj,$whatverb,$where,$desc) = @_;
-    my $hash = get_hashname($ref);
-    open(AP,">>db-h/$hash/$ref.log") || die "opening db-h/$hash/$ref.log (lh): $!";
-    print(AP
-          "\6\n".
-          "<strong>$whatobj $whatverb</strong>".
-          ($where eq '' ? "" : " to <code>".html_escape($where)."</code>").
-          ":<br>\n". $desc.
-          "\n\3\n") || die "writing db-h/$hash/$ref.log (lh): $!";
-    close(AP) || die "closing db-h/$hash/$ref.log (lh): $!";
-}    
+    append_action_to_log(bug => $ref,
+                        action => "$whatobj $whatverb",
+                        requester => '',
+                        request_addr => $where,
+                        desc         => $desc,
+                        get_lock     => 0,
+                       );
+}
 
 sub stripbccs {
     my $msg = shift;
@@ -1132,9 +1131,18 @@ sub bug_list_forward{
      my ($bug_fn) = @_;
      # Read the bug information and package information for passing to
      # the mailing list
+     my $bug_fh = IO::File->new("incoming/P$bug_fn",'r') or
+         die "Unable to open incoming/P$bug_fn $!";
+
+     if (not defined $config{bug_subscription_domain} or not
+        length $config{bug_subscription_domain}) {
+         unlink("incoming/P$bug_fn") or
+              die "unlinking incoming/P$bug_fn: $!";
+         exit 0;
+     }
+
      my ($bug_number) = $bug_fn =~ /^L(\d+)\./;
-     my ($bfound, $data)= lockreadbugmerge($bug_number);
-     my $bug_fh = IO::File->new("incoming/P$bug_fn",'r') or die "Unable to open incoming/P$bug_fn $!";
+     my $data = read_bug(bug => $bug_number);
 
      local $/ = undef;
      my $bug_message = <$bug_fh>;
@@ -1159,10 +1167,10 @@ sub bug_list_forward{
      # If we don't have a bug address, something has gone horribly wrong.
      print STDERR "Doesn't match: $bug_address\n" and exit 1 unless defined $bug_address;
      $bug_address =~ s/\@.+//;
-     print DEBUG "Sending message to bugs=$bug_address\@$gListDomain\n";
+     print DEBUG "Sending message to bugs=$bug_address\@$config{bug_subscription_domain}\n";
      print DEBUG $header.qq(\n\n).$body;
      send_mail_message(message        => $header.qq(\n\n).$body,
-                      recipients     => ["bugs=$bug_address\@$gListDomain"],
+                      recipients     => ["bugs=$bug_address\@$config{bug_subscription_domain}"],
                       envelope_from  => $envelope_from,
                       encode_headers => 0,
                      );