]> git.donarmstrong.com Git - debbugs.git/blobdiff - scripts/process
Include the protocol (http://) in gWebDomain and gCGIDomain
[debbugs.git] / scripts / process
index c663dfd69782a59262095b36424ff5cd07cf6901..089fa46888be91a6234ddaa0cbb80f8d18f5498d 100755 (executable)
@@ -79,6 +79,7 @@ my $debugfh = IO::File->new('/dev/null','w') or
 if ($DEBUG > 0) {
     $debugfh = \*STDERR;
 }
+binmode($debugfh,':raw:encoding(UTF-8)');
 
 # these are the valid bug addresses
 my %baddress = (B => 'submit',
@@ -174,13 +175,14 @@ my %header;
 
 my @common_headers;
 for my $hdr (@headerlines) {
+    my $orig_hdr = $hdr;
     $hdr = decode_rfc1522($hdr);
     $_ = $hdr;
     s/\n\s/ /g;
     finish() if m/^x-loop: (\S+)$/i && $1 eq "$gMaintainerEmail";
     my $ins = !m/^subject:/i && !m/^reply-to:/i && !m/^return-path:/i
            && !m/^From / && !m/^X-Debbugs-/i;
-    $fwd .= $hdr."\n" if $ins;
+    $fwd .= encode_utf8($hdr)."\n" if $ins;
     # print {$debugfh} ">$_<\n";
     if (s/^(\S+):\s*//) {
        my $v = lc $1;
@@ -222,6 +224,7 @@ for my $phline (@bodylines)
     # Remove BOM markers from UTF-8 strings
     # Fixes #488554
     $phline =~ s/\xef\xbb\xbf//g;
+    $phline =~ s/\N{U+FEFF}//g;
     last if $phline !~ m/^([\w-]+):\s*(\S.*)/;
     my ($fn, $fv) = ($1, $2);
     $fv =~ s/\s*$//;
@@ -245,10 +248,12 @@ for my $key (grep /X-Debbugs-.*/i, keys %pheader) {
 # set $i to beginning of encoded body data, so we can dump it out
 # verbatim later
 my $i = 0;
-++$i while $msg[$i] =~ /./;
+++$i while $i <= $#msg and $msg[$i] =~ /./;
 $fwd .= join("\n",@msg[$i..$#msg]);
 
+binmode($debugfh,':raw');
 print {$debugfh} "***\n$fwd\n***\n";
+binmode($debugfh,':raw:encoding(UTF-8)');
 
 if (defined $header{'resent-from'} && !defined $header{'from'}) {
     $header{'from'} = $header{'resent-from'};
@@ -536,10 +541,10 @@ if ($codeletter eq 'D' || $codeletter eq 'F')
               Subject       => "$gBug#$ref closed by $markedby ($header{'subject'})",
               "Message-ID"  => "<handler.$ref.$nn.notifdone\@$gEmailDomain>",
               (defined $data->{msgid})?("In-Reply-To" => $data->{msgid}):(),
-              References    => join(' ',grep {defined $_} ($header{'message-id'},$data->{msgid})),
+              References    => join(' ',grep {defined $_} ($header{'message-id'},$data->{msgid},'')),
               "X-$gProject-PR-Message"  => "they-closed $ref",
-              "X-$gProject-PR-Package"  => "$data->{package}",
-              "X-$gProject-PR-Keywords" => "$data->{keywords}",
+              (defined $data->{package})?("X-$gProject-PR-Package"  => $data->{package}):(),
+              (defined $data->{keywords})?("X-$gProject-PR-Keywords" => $data->{keywords}):(),
              # Only have a X-$gProject-PR-Source when we know the source package
              (defined($source_package) and length($source_package))?("X-$gProject-PR-Source" => $source_package):(),
               "Reply-To"                => "$ref\@$gEmailDomain",
@@ -587,7 +592,8 @@ if ($ref<0) { # new bug report
 
     if (defined $pheader{source}) {
        # source packages are identified by the src: prefix
-        $data->{package} = 'src:'.$pheader{source};
+        $data->{package} = $pheader{source};
+        $data->{package} =~ s/(^|,\s*)/${1}src:/g;
     } elsif (defined $pheader{package}) {
         $data->{package} = $pheader{package};
        if ($data->{package} =~ /^src:(.+)/) {
@@ -1010,7 +1016,7 @@ if (@control_bits) {
         request_subject   => $header{subject},
         request_nn        => $nn,
         request_replyto   => $replyto,
-        message           => $msg,
+        message           => [$msg],
         affected_bugs     => \%bug_affected,
         affected_packages => \%affected_packages,
         recipients        => \%recipients,
@@ -1048,6 +1054,7 @@ if (@control_bits) {
                }
            }
            else {
+               print {$transcript} "Unknown command or malformed arguments to command.\n\n";
                $errors++;
                if (++$unknowns >= 5) {
                    print {$transcript} "Too many unknown commands, stopping here.\n\n";
@@ -1064,7 +1071,7 @@ if (@control_bits) {
                                        address_only => 1,
                                        cc => 1,
                                       );
-    my $error_text = $errors > 0 ? " (with $errors errors)":'';
+    my $error_text = $errors > 0 ? " (with $errors error" . ($errors > 1 ? "s" : "") . ")" : "";
     my $reply =
        create_mime_message(['X-Loop'      => $gMaintainerEmail,
                             From          => "$gMaintainerEmail ($gProject $gBug Tracking System)",
@@ -1202,7 +1209,7 @@ sub sendmessage {
     write_log_records(logfh => $logfh,
                      records => {text => stripbccs($msg),
                                  type => 'recips',
-                                 recips => [@{$recips}],
+                                 recips => [map {encode_utf8($_)} @{$recips}],
                                 },
                     );
     if (ref($bcc)) {
@@ -1255,7 +1262,7 @@ sub fill_template{
                     };
      my $hole_var = {'&bugurl' =>
                     sub{"$_[0]: ".
-                             'http://'.$config{cgi_domain}.'/'.
+                             $config{cgi_domain}.'/'.
                                   Debbugs::CGI::bug_links(bug=>$_[0],
                                                           links_only => 1,
                                                          );