X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FRecipients.pm;h=29b92f72a343d3626126205aad4b3de17b4df14f;hb=fae2d5eea37642cc3773faa697973c25e5e140c2;hp=a73bbd9a91bc933df62b45fa0ad0beb16f62835a;hpb=0a6d62b2d04dc3f6e40d77d652967c4c385cfc5b;p=debbugs.git diff --git a/Debbugs/Recipients.pm b/Debbugs/Recipients.pm index a73bbd9..29b92f7 100644 --- a/Debbugs/Recipients.pm +++ b/Debbugs/Recipients.pm @@ -25,7 +25,7 @@ None known. use warnings; use strict; use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT); -use base qw(Exporter); +use Exporter qw(import); BEGIN{ ($VERSION) = q$Revision: 1221 $ =~ /^Revision:\s+([^\s+])/; @@ -46,7 +46,7 @@ use Params::Validate qw(:types validate_with); use Debbugs::Common qw(:misc :util); use Debbugs::Status qw(splitpackages isstrongseverity); -use Debbugs::Packages qw(binarytosource); +use Debbugs::Packages qw(binary_to_source); use Debbugs::Mail qw(get_addresses); @@ -94,6 +94,9 @@ sub add_recipients { actions_taken => {type => HASHREF, default => {}, }, + unknown_packages => {type => HASHREF, + default => {}, + }, }, ); @@ -103,18 +106,19 @@ sub add_recipients { for my $data (@{$param{data}}) { add_recipients(data => $data, map {exists $param{$_}?($_,$param{$_}):()} - qw(recipients debug transcript actions_taken) + qw(recipients debug transcript actions_taken unknown_packages) ); } return; } - my ($p, $addmaint); - my $anymaintfound=0; my $anymaintnotfound=0; + my ($addmaint); my $ref = $param{data}{bug_num}; for my $p (splitpackages($param{data}{package})) { $p = lc($p); if (defined $config{subscription_domain}) { - my @source_packages = binarytosource($p); + my @source_packages = binary_to_source(binary => $p, + source_only => 1, + ); if (@source_packages) { for my $source (@source_packages) { _add_address(recipients => $param{recipients}, @@ -140,20 +144,23 @@ sub add_recipients { type => 'bcc', ); } - if (defined(getmaintainers()->{$p})) { - $addmaint= getmaintainers()->{$p}; - print {$param{debug}} "MR|$addmaint|$p|$ref|\n"; - _add_address(recipients => $param{recipients}, - address => $addmaint, - reason => $p, - bug_num => $param{data}{bug_num}, - type => 'cc', - ); - print {$param{debug}} "maintainer add >$p|$addmaint<\n"; + my @maints = package_maintainer(binary => $p); + if (@maints) { + print {$param{debug}} "MR|".join(',',@maints)."|$p|$ref|\n"; + _add_address(recipients => $param{recipients}, + address => \@maints, + reason => $p, + bug_num => $param{data}{bug_num}, + type => 'cc', + ); + print {$param{debug}} "maintainer add >$p|".join(',',@maints)."<\n"; } - else { + else { print {$param{debug}} "maintainer none >$p<\n"; - print {$param{transcript}} "Warning: Unknown package '$p'\n"; + if (not exists $param{unknown_packages}{$p}) { + print {$param{transcript}} "Warning: Unknown package '$p'\n"; + $param{unknown_packages}{$p} = 1; + } print {$param{debug}} "MR|unknown-package|$p|$ref|\n"; _add_address(recipients => $param{recipients}, address => $config{unknown_maintainer_email}, @@ -168,12 +175,22 @@ sub add_recipients { if (defined $config{bug_subscription_domain} and length $config{bug_subscription_domain}) { _add_address(recipients => $param{recipients}, - address => 'bug='.$param{data}{bug_num}.'@'. + address => 'bugs='.$param{data}{bug_num}.'@'. $config{bug_subscription_domain}, reason => "bug $param{data}{bug_num}", bug_num => $param{data}{bug_num}, type => 'bcc', ); + } + if (defined $config{cc_all_mails_to_addr} and + length $config{cc_all_mails_to_addr} + ) { + _add_address(recipients => $param{recipients}, + address => $config{cc_all_mails_to}, + reason => "cc_all_mails_to", + bug_num => $param{data}{bug_num}, + type => 'bcc', + ); } if (length $param{data}{owner}) { @@ -237,7 +254,7 @@ Using the recipient hashref, determines the set of recipients. If you specify one of C, C, or C, you will receive only a LIST of recipients which the main should be Bcc'ed, Cc'ed, or To'ed respectively. By default, a LIST with keys bcc, cc, and to is returned -with ARRAYREF values correponding to the users to whom a message +with ARRAYREF values corresponding to the users to whom a message should be sent. =over @@ -291,8 +308,13 @@ sub determine_recipients { $level = 'cc'; } } - # strip out all non-word non-spaces - $reason =~ s/[^\ \w]//g; + # RFC 2822 comments cannot contain specials and + # unquoted () or \; there's no reason for us to allow + # insane things here, though, so we restrict this even + # more to 20-7E ( -~) + $reason =~ s/\\/\\\\/g; + $reason =~ s/([\)\(])/\\$1/g; + $reason =~ s/[^\x20-\x7E]//g; push @reasons, $reason . ' for {'.join(',',@bugs).'}'; } if ($param{address_only}) {