X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debbugs%2FControl.pm;h=416abc150104741bff85625bb03353ab0930a3dd;hb=4118f90e5b711616eeff28aef36615b0a892b57f;hp=39e6648bbe8478aea8e28b07e454007f0c8f4e3d;hpb=b589eb07e8c620e6daa2ac0dcd65f7d68f242814;p=debbugs.git
diff --git a/Debbugs/Control.pm b/Debbugs/Control.pm
index 39e6648..416abc1 100644
--- a/Debbugs/Control.pm
+++ b/Debbugs/Control.pm
@@ -75,7 +75,7 @@ is true, the above options must be present, and their values are used.
use warnings;
use strict;
use vars qw($VERSION $DEBUG %EXPORT_TAGS @EXPORT_OK @EXPORT);
-use base qw(Exporter);
+use Exporter qw(import);
BEGIN{
$VERSION = 1.00;
@@ -110,7 +110,8 @@ BEGIN{
}
use Debbugs::Config qw(:config);
-use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions :utf8);
+use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions);
+use Debbugs::UTF8;
use Debbugs::Status qw(bug_archiveable :read :hook writebug new_bug splitpackages split_status_fields get_bug_status);
use Debbugs::CGI qw(html_escape);
use Debbugs::Log qw(:misc :write);
@@ -125,7 +126,7 @@ use IO::File;
use Debbugs::Text qw(:templates);
-use Debbugs::Mail qw(rfc822_date send_mail_message default_headers);
+use Debbugs::Mail qw(rfc822_date send_mail_message default_headers encode_headers);
use Debbugs::MIME qw(create_mime_message);
use Mail::RFC822::Address qw();
@@ -1115,7 +1116,7 @@ sub set_submitter {
}
else {
if (defined $data->{originator} and length($data->{originator})) {
- $action= "Changed $config{bug} submitter to '$param{submitter}' from '$data->{originator}'";
+ $action= "Changed $config{bug} submitter to '$param{submitter}' from '$data->{originator}'.";
$notify_old_submitter = 1;
}
else {
@@ -1230,7 +1231,7 @@ sub set_forwarded {
$action= "Unset $config{bug} forwarded-to-address";
}
elsif (defined $data->{forwarded} and length($data->{forwarded})) {
- $action= "Changed $config{bug} forwarded-to-address to '$param{forwarded}' from '$data->{forwarded}'";
+ $action= "Changed $config{bug} forwarded-to-address to '$param{forwarded}' from '$data->{forwarded}'.";
}
else {
$action= "Set $config{bug} forwarded-to-address to '$param{forwarded}'.";
@@ -1315,7 +1316,7 @@ sub set_title {
}
else {
if (defined $data->{subject} and length($data->{subject})) {
- $action= "Changed $config{bug} title to '$param{title}' from '$data->{subject}'";
+ $action= "Changed $config{bug} title to '$param{title}' from '$data->{subject}'.";
} else {
$action= "Set $config{bug} title to '$param{title}'.";
}
@@ -1578,7 +1579,11 @@ sub set_found {
if (not @svers) {
@svers = $version;
}
- else {
+ elsif (not grep {$version eq $_} @svers) {
+ # The $version was not equal to one of the source
+ # versions, so it's probably unqualified (or just
+ # wrong). Delete it, and use the source versions
+ # instead.
if (exists $found_versions{$version}) {
delete $found_versions{$version};
$found_removed{$version} = 1;
@@ -1591,7 +1596,7 @@ sub set_found {
}
# if the found we are adding matches any fixed
# versions, remove them
- my @temp = grep m{(^|/)\Q$sver\E}, keys %fixed_versions;
+ my @temp = grep m{(^|/)\Q$sver\E$}, keys %fixed_versions;
delete $fixed_versions{$_} for @temp;
$fixed_removed{$_} = 1 for @temp;
}
@@ -1615,7 +1620,7 @@ sub set_found {
# in the case of removal, we only concern ourself with
# the version passed, not the source version it maps
# to
- my @temp = grep m{(^|/)\Q$version\E}, keys %found_versions;
+ my @temp = grep m{(?:^|/)\Q$version\E$}, keys %found_versions;
delete $found_versions{$_} for @temp;
$found_removed{$_} = 1 for @temp;
}
@@ -2658,7 +2663,7 @@ Handles all setting of summary fields
If summary is undef, unsets the summary
-If summary is 0, sets the summary to the first paragraph contained in
+If summary is 0 or -1, sets the summary to the first paragraph contained in
the message passed.
If summary is a positive integer, sets the summary to the message specified.
@@ -2743,10 +2748,10 @@ sub _summary {
print {$debug} "Removing $cmd fields\n";
$action = "Removed $cmd";
}
- elsif ($param{$cmd} =~ /^\d+$/) {
+ elsif ($param{$cmd} =~ /^-?\d+$/) {
my $log = [];
my @records = Debbugs::Log::read_log_records(bug_num => $param{bug});
- if ($param{$cmd} == 0) {
+ if ($param{$cmd} == 0 or $param{$cmd} == -1) {
$log = $param{message};
$summary_msg = @records + 1;
}
@@ -2780,7 +2785,7 @@ sub _summary {
}
# skip a paragraph if it looks like it's control or
# pseudo-headers
- if ($line =~ m{^\s*(?:Package|Source|Version|User|Tag|Severity)\:\s+\S}xi or #pseudo headers
+ if ($line =~ m{^\s*(?:Package|Source|Version|User|Tag|Severity|Control)\:\s+\S}xi or #pseudo headers
$line =~ m{^(?:package:?|(?:no|)owner|severity|tags?|summary| #control
\#|reopen|close|(?:not|)(?:fixed|found)|clone|
debug|(?:not|)forwarded|priority|
@@ -2958,19 +2963,19 @@ sub clone_bug {
# bugs that this bug is blocking are also blocked by the new clone(s)
for my $bug (split ' ', $data->{blocks}) {
for my $new_bug (@new_bugs) {
- set_blocks(bug => $new_bug,
- block => $bug,
+ set_blocks(bug => $bug,
+ block => $new_bug,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
);
}
}
- # bugs that this bug is blocked by are also blocking the new clone(s)
+ # bugs that are blocking this bug are also blocking the new clone(s)
for my $bug (split ' ', $data->{blockedby}) {
for my $new_bug (@new_bugs) {
- set_blocks(bug => $bug,
- block => $new_bug,
+ set_blocks(bug => $new_bug,
+ block => $bug,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
@@ -3433,25 +3438,25 @@ sub append_action_to_log{
}
my $msg = join('',
(exists $param{command} ?
- "\n":""
+ "\n":""
),
(length $param{requester} ?
- "\n":""
+ "\n":""
),
(length $param{request_addr} ?
- "\n":""
+ "\n":""
),
"\n",
$data_diff,
- "".html_escape(encode_utf8($param{action}))."\n");
+ "".html_escape(encode_utf8_safely($param{action}))."\n");
if (length $param{requester}) {
- $msg .= "Request was from ".html_escape(encode_utf8($param{requester}))."
\n";
+ $msg .= "Request was from ".html_escape(encode_utf8_safely($param{requester}))."
\n";
}
if (length $param{request_addr}) {
- $msg .= "to ".html_escape(encode_utf8($param{request_addr}))."
";
+ $msg .= "to ".html_escape(encode_utf8_safely($param{request_addr}))."
";
}
if (length $param{desc}) {
- $msg .= ":
\n".encode_utf8($param{desc})."\n";
+ $msg .= ":
\n".encode_utf8_safely($param{desc})."\n";
}
else {
$msg .= ".\n";
@@ -3462,7 +3467,7 @@ sub append_action_to_log{
$msg = '';
if ((ref($param{message}) and @{$param{message}}) or length($param{message})) {
push @records, {type => exists $param{recips}?'recips':'incoming-recv',
- exists $param{recips}?(recips => [make_list($param{recips})]):(),
+ exists $param{recips}?(recips => [map {encode_utf8_safely($_)} make_list($param{recips})]):(),
text => join('',make_list($param{message})),
};
}
@@ -3586,13 +3591,14 @@ sub __return_append_to_log_options{
}
if (not exists $param{message}) {
my $date = rfc822_date();
- $param{message} = fill_in_template(template => 'mail/fake_control_message',
- variables => {request_addr => $param{request_addr},
- requester => $param{requester},
- date => $date,
- action => $action
- },
- );
+ $param{message} =
+ encode_headers(fill_in_template(template => 'mail/fake_control_message',
+ variables => {request_addr => $param{request_addr},
+ requester => $param{requester},
+ date => $date,
+ action => $action
+ },
+ ));
}
if (not defined $action) {
carp "Undefined action!";