X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scripts%2Fprocess;h=516bd314505089aee2e1ae84360714dbdd746efb;hb=4a71b4c56f1bb4bfc9fb3fc7915511ea4a557800;hp=4236f6b4ccbdece729d1f8488c8cc0bf4afc204e;hpb=29c59ac17e0457ce9d429a7282a5d22d383816d5;p=debbugs.git diff --git a/scripts/process b/scripts/process index 4236f6b..516bd31 100755 --- a/scripts/process +++ b/scripts/process @@ -7,7 +7,9 @@ use warnings; use strict; -use POSIX qw(strftime); +use locale; +use POSIX qw(strftime locale_h); +setlocale(LC_TIME, "C"); use IO::File; @@ -77,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', @@ -84,7 +87,7 @@ my %baddress = (B => 'submit', Q => 'quiet', F => 'forwarded', D => 'done', - S => 'submitter', + U => 'submitter', L => 'list', ); my $valid_codeletters = join('',keys %baddress); @@ -172,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; @@ -220,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*$//; @@ -246,7 +251,9 @@ my $i = 0; ++$i while $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'}; @@ -271,16 +278,32 @@ if (!defined($header{'subject'})) } my $ref=-1; -$subject =~ s/^Re:\s*//i; $_= $subject."\n"; +# remove Re: from the subject line +$subject =~ s/^Re:\s*//i; +# remove remaining mailing list name markers from the subject line if +# this appears to be a message that has traversed a mailing list +if (exists $header{'list-id'} or exists $header{'list-subscribe'} or + (exists $header{'precedence'} and defined $header{'precedence'} and + $header{'precedence'} eq 'bulk') or + exists $header{'mailing-list'} or exists $header{'list-processor-version'} + ){ + # if a mailing list didn't match any of the above, it's probably + # so horribly configured that we wouldn't be able to figure it out + # anyway. + $subject =~ s/^\[.*\]\s*//i; +} +$_= $subject."\n"; if (not defined $tryref and m/^Bug ?\#(\d+)\D/i) { $tryref = $1 if $1 > 0; } +my $locks = 0; my $data; if (defined $tryref) { - my $bfound; - ($bfound, $data)= &lockreadbugmerge($tryref); - if ($bfound and not $data->{archived}) { - $ref= $tryref; + my $locks_recv; + ($locks_recv, $data)= &lockreadbugmerge($tryref); + $locks += $locks_recv; + if ($locks_recv and not $data->{archived}) { + $ref= $tryref; } else { &sendmessage(create_mime_message( [From => "$gMaintainerEmail ($gProject $gBug Tracking System)", @@ -408,8 +431,10 @@ if ($codeletter eq 'D' || $codeletter eq 'F') for $ref (@process) { if ($ref != $orgref) { &unfilelock; + $locks--; $data = &lockreadbug($ref) || die "huh ? $ref from $orgref out of ".join(' ',@process); + $locks++; } $data->{done}= $set_done if defined($set_done); $data->{forwarded}= $set_forwarded if defined($set_forwarded); @@ -439,8 +464,14 @@ if ($codeletter eq 'D' || $codeletter eq 'F') # Add bug mailing list to $generalbcc as appropriate # This array is used to specify bcc in the cases where we're using create_mime_message. - my @generalbcc = (@generalcc,@addsrcaddrs,"bugs=$ref\@$gListDomain"); - my $generalbcc = join(', ', $generalcc, @addsrcaddrs,"bugs=$ref\@$gListDomain"); + my @generalbcc = @generalcc; + if (defined $config{subscription_domain} and length $config{subscription_domain}) { + @generalbcc = (@generalbcc, @addsrcaddrs); + } + if (defined $config{bug_subscription_domain} and length $config{bug_subscription_domain}) { + @generalbcc = (@generalbcc, "bugs=$ref\@$config{bug_subscription_domain}"); + } + my $generalbcc = join(', ', @generalbcc); $generalbcc =~ s/\s+\n\s+/ /g; $generalbcc =~ s/^\s+/ /; $generalbcc =~ s/\s+$//; if (length $generalbcc) {$generalbcc = "Bcc: $generalbcc\n"}; @@ -510,10 +541,10 @@ if ($codeletter eq 'D' || $codeletter eq 'F') Subject => "$gBug#$ref closed by $markedby ($header{'subject'})", "Message-ID" => "", (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", @@ -713,7 +744,9 @@ if (defined $gStrongList and isstrongseverity($data->{severity})) { } # Send mail to the per bug list subscription too -push @bccs, "bugs=$ref\@$gListDomain"; +if (defined $config{bug_subscription_domain} and length $config{bug_subscription_domain}) { + push @bccs, "bugs=$ref\@$config{bug_subscription_domain}"; +} if (defined $pheader{source}) { # Prefix source versions with the name of the source package. They @@ -956,6 +989,8 @@ if (not exists $header{'x-debbugs-no-ack'} and } appendlog($ref,$msg); +# unlock the locks we have received +while ($locks--) {unfilelock();} ## handle control messages at this point, immediately before finishing my %clonebugs = (-1 => $ref); @@ -990,7 +1025,6 @@ if (@control_bits) { print {$transcript} fill_template('mail/excluded_from_control'); print {$transcript} "Stopping processing here.\n\n"; } else { - my %clonebugs = (); for my $control_bit (@control_bits) { $control_bit =~ s/\xef\xbb\xbf//g; next unless $control_bit =~ m/\S/; @@ -1012,12 +1046,14 @@ if (@control_bits) { transcript => $transcript, debug => 0, ok => \$ok, + replyto => $replyto, ); if ($terminate_control) { last; } } 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"; @@ -1172,7 +1208,7 @@ sub sendmessage { write_log_records(logfh => $logfh, records => {text => stripbccs($msg), type => 'recips', - recips => [@{$recips}], + recips => [map {encode_utf8($_)} @{$recips}], }, ); if (ref($bcc)) { @@ -1250,15 +1286,15 @@ sub checkmaintainers { $p =~ /((?:src:)?[a-z0-9.+-]+)/; $p = $1; next unless defined $p; - if (defined $gSubscriptionDomain) { + if (defined $config{subscription_domain} and length $config{subscription_domain}) { my @source = binary_to_source(binary => $p, source_only => 1, ); if (@source) { push @addsrcaddrs, - map {"$_\@$gSubscriptionDomain"} @source; + map {"$_\@$config{subscription_domain}"} @source; } else { - push @addsrcaddrs, "$p\@$gSubscriptionDomain"; + push @addsrcaddrs, "$p\@$config{subscription_domain}"; } } # this is utter hackery until we switch to Debbugs::Recipients