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;
severity => [qw(set_severity)],
affects => [qw(affects)],
summary => [qw(summary)],
+ outlook => [qw(outlook)],
owner => [qw(owner)],
title => [qw(set_title)],
forward => [qw(set_forwarded)],
clone => [qw(clone_bug)],
archive => [qw(bug_archive bug_unarchive),
],
+ limit => [qw(check_limit)],
log => [qw(append_action_to_log),
],
);
use Debbugs::Config qw(:config);
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);
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();
use POSIX qw(strftime);
use Storable qw(dclone nfreeze);
-use List::Util qw(first max);
+use List::AllUtils qw(first max);
+use Encode qw(encode_utf8);
use Carp;
next if $ok_blockers{$blocker} or $bad_blockers{$blocker};
my $data = read_bug(bug=>$blocker,
);
- if (defined $data and not $data->{archive}) {
+ if (defined $data and not $data->{archived}) {
$data = split_status_fields($data);
$ok_blockers{$blocker} = 1;
my @merged_bugs;
# throw an error if we are setting the blockers and there is a bad
# blocker
if (keys %bad_blockers and $mode eq 'set') {
- croak "Unknown blocking bug(s):".join(', ',keys %bad_blockers).
- keys %ok_blockers?'':" and no known blocking bug(s)";
+ __end_control(%info);
+ croak "Unknown/archived blocking bug(s):".join(', ',keys %bad_blockers).
+ keys %ok_blockers?'':" and no good blocking bug(s)";
}
# if there are no ok blockers and we are not setting the blockers,
# there's an error.
if (not keys %ok_blockers and $mode ne 'set') {
print {$transcript} "No valid blocking bug(s) given; not doing anything\n";
if (keys %bad_blockers) {
- croak "Unknown blocking bug(s):".join(', ',keys %bad_blockers);
+ __end_control(%info);
+ croak "Unknown/archived blocking bug(s):".join(', ',keys %bad_blockers);
}
__end_control(%info);
return;
@bugs{@bugs} = (1) x @bugs;
for my $blocker (@change_blockers) {
if ($bugs{$blocker}) {
+ __end_control(%info);
croak "It is nonsensical for a bug to block itself (or a merged partner): $blocker";
}
}
}
}
}
- my @new_blockers = keys %blockers;
for my $data (@data) {
my $old_data = dclone($data);
# remove blockers and/or add new ones as appropriate
$mungable_blocks{add} = \%added_blockers if keys %added_blockers;
my $new_locks = 0;
for my $add_remove (keys %mungable_blocks) {
- my @munge_blockers;
my %munge_blockers;
- my $block_locks = 0;
for my $blocker (keys %{$mungable_blocks{$add_remove}}) {
next if $munge_blockers{$blocker};
my ($temp_locks, @blocking_data) =
__begin_control(%param,
command => 'tag'
);
- my ($debug,$transcript) =
- @info{qw(debug transcript)};
+ my $transcript = $info{transcript};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my @tags = make_list($param{tag});
if (not @tags and ($param{remove} or $param{add})) {
if ($param{remove}) {
my $action = 'Did not alter tags';
my %tag_added = ();
my %tag_removed = ();
- my %fixed_removed = ();
my @old_tags = split /\,?\s+/, $data->{keywords};
my %tags;
@tags{@old_tags} = (1) x @old_tags;
- my $reopened = 0;
my $old_data = dclone($data);
if (not $param{add} and not $param{remove}) {
$tag_removed{$_} = 1 for @old_tags;
__begin_control(%param,
command => 'severity'
);
- my ($debug,$transcript) =
- @info{qw(debug transcript)};
+ my $transcript = $info{transcript};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
for my $data (@data) {
__begin_control(%param,
command => $param{reopen}?'reopen':'done',
);
- my ($debug,$transcript) =
- @info{qw(debug transcript)};
+ my $transcript = $info{transcript};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action ='';
if ($param{reopen}) {
}
else {
my %submitter_notified;
- my $requester_notified = 0;
my $orig_report_set = 0;
for my $data (@data) {
if (exists $data->{done} and
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
# here we only concern ourselves with the first of the merged bugs
for my $data ($data[0]) {
}
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 {
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
for my $data (@data) {
my $old_data = dclone($data);
$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}'.";
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
for my $data (@data) {
my $old_data = dclone($data);
}
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}'.";
}
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
# clean up the new package
my $new_package =
join(',',
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my %versions;
for my $version (make_list($param{found})) {
next unless defined $version;
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;
}
# 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;
}
# 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;
}
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my %versions;
for my $version (make_list($param{fixed})) {
next unless defined $version;
return;
}
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my %data;
my %merged_bugs;
for my $data (@data) {
# handle unmerging
my $new_locks = 0;
if (not exists $param{merge_with}) {
- my $ok_to_unmerge = 1;
delete $merged_bugs{$param{bug}};
if (not keys %merged_bugs) {
print {$transcript} "Ignoring request to unmerge a bug which is not merged with any others.\n";
$data->{mergedwith} = '';
}
else {
- $data->{mergedwith} = join(' ',sort grep {$_ != $data->{bug_num}}
- keys %merged_bugs);
+ $data->{mergedwith} =
+ join(' ',
+ sort {$a <=> $b}
+ grep {$_ != $data->{bug_num}}
+ keys %merged_bugs);
}
append_action_to_log(bug => $data->{bug_num},
command => 'merge',
return;
}
# lock and load all of the bugs we need
- my @bugs_to_load = keys %merging;
- my $bug_to_load;
- my %merge_added;
my ($data,$n_locks) =
__lock_and_load_merged_bugs(bugs_to_load => [keys %merging],
data => \@data,
$new_locks += $n_locks;
%data = %{$data};
@data = values %data;
- if (not __check_limit(data => [@data],
+ if (not check_limit(data => [@data],
exists $param{limit}?(limit => $param{limit}):(),
transcript => $transcript,
)) {
print {$transcript} "$change->{field} of #$change->{bug} is '$change->{text_orig_value}' not '$change->{text_value}'\n";
}
if ($attempts > 0) {
+ __end_control(%info);
croak "Some bugs were altered while attempting to merge";
}
else {
+ __end_control(%info);
croak "Did not alter merged bugs";
}
}
$param{show_bug_info} and not __internal_request(1);
$bug_info_shown{$change_bug} = 1;
__allow_relocking($param{locks},[keys %data]);
+ eval {
for my $change (@{$changes->{$change_bug}}) {
if ($change->{field} eq 'blockedby' or $change->{field} eq 'blocks') {
my %target_blockedby;
@target_blockedby{@{$change->{func_value}}} = (1) x @{$change->{func_value}};
my %unhandled_targets = %target_blockedby;
- my @blocks_to_remove;
for my $key (split / /,$change->{orig_value}) {
delete $unhandled_targets{$key};
next if exists $target_blockedby{$key};
);
}
}
+ };
+ if ($@) {
+ __disallow_relocking($param{locks});
+ __end_control(%info);
+ croak "Failure while trying to adjust bugs, please report this as a bug: $@";
+ }
__disallow_relocking($param{locks});
my ($data,$n_locks) =
__lock_and_load_merged_bugs(bugs_to_load => [keys %merging],
$locks--;
}
__end_control(%info);
- for my $change (values %{$changes}, @{$disallowed_changes}) {
+ for my $change ((map {@{$_}} values %{$changes}), @{$disallowed_changes}) {
print {$transcript} "$change->{field} of #$change->{bug} is '$change->{text_orig_value}' not '$change->{text_value}'\n";
}
die "Unable to modify bugs so they could be merged";
}
# finally, we can merge the bugs
- my $action = "Merged ".join(' ',sort keys %merged_bugs);
+ my $action = "Merged ".join(' ',sort { $a <=> $b } keys %merged_bugs);
for my $data (@data) {
my $old_data = dclone($data);
- $data->{mergedwith} = join(' ',sort grep {$_ != $data->{bug_num}}
- keys %merged_bugs);
+ $data->{mergedwith} =
+ join(' ',
+ sort { $a <=> $b }
+ grep {$_ != $data->{bug_num}}
+ keys %merged_bugs);
append_action_to_log(bug => $data->{bug_num},
command => 'merge',
new_data => $data,
$merged_bugs{$data->{bug_num}} = 1;
$bugs_to_merge = 1;
}
+ }
+ for my $data (@{$data_a}) {
# the master_bug is the bug that every other bug is made to
# look like. However, if merge is set, tags, fixed and found
# are merged.
if ($data->{bug_num} == $master_bug) {
- for (qw(package forwarded severity blocks blockedby done owner summary affects)) {
+ for (qw(package forwarded severity done owner summary outlook affects)) {
$merge_status{$_} = $data->{$_}
}
+ # bugs which are in the newly merged set and are also
+ # blocks/blockedby must be removed before merging
+ for (qw(blocks blockedby)) {
+ $merge_status{$_} =
+ join(' ',grep {not exists $merged_bugs{$_}}
+ split / /,$data->{$_});
+ }
}
if (defined $merge_status) {
next unless $data->{bug_num} == $master_bug;
@{$merge_status{"${_}_versions"}}{@{$data->{"${_}_versions"}}} = (1) x @{$data->{"${_}_versions"}};
}
}
+ # if there is a non-source qualified version with a corresponding
+ # source qualified version, we only want to merge the source
+ # qualified version(s)
+ for (qw(fixed found)) {
+ my @unqualified_versions = grep {m{/}?0:1} keys %{$merge_status{"${_}_versions"}};
+ for my $unqualified_version (@unqualified_versions) {
+ if (grep {m{/\Q$unqualified_version\E}} keys %{$merge_status{"${_}_versions"}}) {
+ delete $merge_status{"${_}_versions"}{$unqualified_version};
+ }
+ }
+ }
return (\%merge_status,$bugs_to_merge);
}
key => 'summary',
options => [],
},
+ outlook => {func => \&outlook,
+ key => 'outlook',
+ options => [],
+ },
affects => {func => \&affects,
key => 'package',
options => [],
allowed => 1,
},
);
- for my $field (qw(forwarded severity blocks blockedby done owner summary affects package fixed_versions found_versions keywords)) {
+ for my $field (qw(forwarded severity blocks blockedby done owner summary outlook affects package fixed_versions found_versions keywords)) {
# if the ideal bug already has the field set properly, we
# continue on.
if ($field eq 'keywords'){
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
for my $data (@data) {
$action = '';
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.
sub summary {
- my %param = validate_with(params => \@_,
+ # outlook and summary are exactly the same, basically
+ return _summary('summary',@_);
+}
+
+=head1 OUTLOOK FUNCTIONS
+
+=head2 outlook
+
+ eval {
+ outlook(bug => $ref,
+ transcript => $transcript,
+ ($dl > 0 ? (debug => $transcript):()),
+ requester => $header{from},
+ request_addr => $controlrequestaddr,
+ message => \@log,
+ affected_packages => \%affected_packages,
+ recipients => \%recipients,
+ outlook => undef,
+ );
+ };
+ if ($@) {
+ $errors++;
+ print {$transcript} "Failed to mark $ref with outlook foo: $@";
+ }
+
+Handles all setting of outlook fields
+
+If outlook is undef, unsets the outlook
+
+If outlook is 0, sets the outlook to the first paragraph contained in
+the message passed.
+
+If outlook is a positive integer, sets the outlook to the message specified.
+
+Otherwise, sets outlook to the value passed.
+
+=cut
+
+
+sub outlook {
+ return _summary('outlook',@_);
+}
+
+sub _summary {
+ my ($cmd,@params) = @_;
+ my %param = validate_with(params => \@params,
spec => {bug => {type => SCALAR,
regex => qr/^\d+$/,
},
# specific options here
- summary => {type => SCALAR|UNDEF,
- default => 0,
- },
+ $cmd , {type => SCALAR|UNDEF,
+ default => 0,
+ },
%common_options,
%append_action_options,
},
);
-# croak "summary must be numeric or undef" if
-# defined $param{summary} and not $param{summary} =~ /^\d+/;
my %info =
__begin_control(%param,
- command => 'summary'
+ command => $cmd,
);
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
# figure out the log that we're going to use
my $summary = '';
my $summary_msg = '';
my $action = '';
- if (not defined $param{summary}) {
+ if (not defined $param{$cmd}) {
# do nothing
- print {$debug} "Removing summary fields\n";
- $action = 'Removed summary';
+ print {$debug} "Removing $cmd fields\n";
+ $action = "Removed $cmd";
}
- elsif ($param{summary} =~ /^\d+$/) {
+ elsif ($param{$cmd} =~ /^-?\d+$/) {
my $log = [];
my @records = Debbugs::Log::read_log_records(bug_num => $param{bug});
- if ($param{summary} == 0) {
+ if ($param{$cmd} == 0 or $param{$cmd} == -1) {
$log = $param{message};
$summary_msg = @records + 1;
}
else {
- if (($param{summary} - 1 ) > $#records) {
- die "Message number '$param{summary}' exceeds the maximum message '$#records'";
+ if (($param{$cmd} - 1 ) > $#records) {
+ die "Message number '$param{$cmd}' exceeds the maximum message '$#records'";
}
- my $record = $records[($param{summary} - 1 )];
+ my $record = $records[($param{$cmd} - 1 )];
if ($record->{type} !~ /incoming-recv|recips/) {
- die "Message number '$param{summary}' is a invalid message type '$record->{type}'";
+ die "Message number '$param{$cmd}' is a invalid message type '$record->{type}'";
}
- $summary_msg = $param{summary};
+ $summary_msg = $param{$cmd};
$log = [$record->{text}];
}
my $p_o = Debbugs::MIME::parse(join('',@{$log}));
}
# 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|
(?:un|)block|limit|(?:un|)archive|
- reassign|retitle|affects|wrongpackage
+ reassign|retitle|affects|package|
+ outlook|
(?:un|force|)merge|user(?:category|tags?|)
)\s+\S}xis) {
if (not length $paragraph) {
next if $in_pseudoheaders;
$paragraph .= $line ." \n";
}
- print {$debug} "Summary is going to be '$paragraph'\n";
+ print {$debug} ucfirst($cmd)." is going to be '$paragraph'\n";
$summary = $paragraph;
$summary =~ s/[\n\r]/ /g;
if (not length $summary) {
- die "Unable to find summary message to use";
+ die "Unable to find $cmd message to use";
}
# trim off a trailing spaces
$summary =~ s/\ *$//;
}
else {
- $summary = $param{summary};
+ $summary = $param{$cmd};
}
for my $data (@data) {
- print {$debug} "Going to change summary\n";
+ print {$debug} "Going to change $cmd\n";
if (((not defined $summary or not length $summary) and
- (not defined $data->{summary} or not length $data->{summary})) or
- $summary eq $data->{summary}) {
- print {$transcript} "Ignoring request to change the summary of bug $param{bug} to the same value\n";
+ (not defined $data->{$cmd} or not length $data->{$cmd})) or
+ $summary eq $data->{$cmd}) {
+ print {$transcript} "Ignoring request to change the $cmd of bug $param{bug} to the same value\n";
next;
}
if (length $summary) {
- if (length $data->{summary}) {
- $action = "Summary replaced with message bug $param{bug} message $summary_msg";
+ if (length $data->{$cmd}) {
+ $action = ucfirst($cmd)." replaced with message bug $param{bug} message $summary_msg";
}
else {
- $action = "Summary recorded from message bug $param{bug} message $summary_msg";
+ $action = ucfirst($cmd)." recorded from message bug $param{bug} message $summary_msg";
}
}
my $old_data = dclone($data);
- $data->{summary} = $summary;
+ $data->{$cmd} = $summary;
append_action_to_log(bug => $data->{bug_num},
- command => 'summary',
+ command => $cmd,
old_data => $old_data,
new_data => $data,
get_lock => 0,
__begin_control(%param,
command => 'clone'
);
- my ($debug,$transcript) =
- @info{qw(debug transcript)};
+ my $transcript = $info{transcript};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
for my $data (@data) {
# 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,
- blocks => $bug,
+ set_blocks(bug => $bug,
+ block => $new_bug,
+ add => 1,
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,
- blocks => $new_bug,
+ set_blocks(bug => $new_bug,
+ block => $bug,
+ add => 1,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
my ($debug,$transcript) =
@info{qw(debug transcript)};
my @data = @{$info{data}};
- my @bugs = @{$info{bugs}};
my $action = '';
for my $data (@data) {
print {$debug} "Going to change owner to '".(defined $param{owner}?$param{owner}:'(going to unset it)')."'\n";
command=>'unarchive');
my ($debug,$transcript) =
@info{qw(debug transcript)};
- my @data = @{$info{data}};
my @bugs = @{$info{bugs}};
my $action = "$config{bug} unarchived.";
my @files_to_remove;
+ ## error out if we're unarchiving unarchived bugs
+ for my $data (@{$info{data}}) {
+ if (not defined $data->{archived} or
+ not $data->{archived}
+ ) {
+ __end_control(%info);
+ croak("Bug $data->{bug_num} was not archived; not unarchiving it.");
+ }
+ }
for my $bug (@bugs) {
print {$debug} "$param{bug} removing $bug\n";
my $dir = get_hashname($bug);
$nd{$key} = $new_data->{$key};
# $data_diff .= html_escape("$Debbugs::Status::fields{$key}: $new_data->{$key}")."\n";
}
- $data_diff .= html_escape(Data::Dumper->Dump([\%nd],[qw(new_data)]));
+ $data_diff .= html_escape(Data::Dumper->Dump([encode_utf8_structure(\%nd)],[qw(new_data)]));
$data_diff .= "-->\n";
$data_diff .= "<!-- old_data:\n";
my %od;
$od{$key} = $old_data->{$key};
# $data_diff .= html_escape("$Debbugs::Status::fields{$key}: $old_data->{$key}")."\n";
}
- $data_diff .= html_escape(Data::Dumper->Dump([\%od],[qw(old_data)]));
+ $data_diff .= html_escape(Data::Dumper->Dump([encode_utf8_structure(\%od)],[qw(old_data)]));
$data_diff .= "-->\n";
}
my $msg = join('',
(exists $param{command} ?
- "<!-- command:".html_escape($param{command})." -->\n":""
+ "<!-- command:".html_escape(encode_utf8_safely($param{command}))." -->\n":""
),
(length $param{requester} ?
- "<!-- requester: ".html_escape($param{requester})." -->\n":""
+ "<!-- requester: ".html_escape(encode_utf8_safely($param{requester}))." -->\n":""
),
(length $param{request_addr} ?
- "<!-- request_addr: ".html_escape($param{request_addr})." -->\n":""
+ "<!-- request_addr: ".html_escape(encode_utf8_safely($param{request_addr}))." -->\n":""
),
"<!-- time:".time()." -->\n",
$data_diff,
- "<strong>".html_escape($param{action})."</strong>\n");
+ "<strong>".html_escape(encode_utf8_safely($param{action}))."</strong>\n");
if (length $param{requester}) {
- $msg .= "Request was from <code>".html_escape($param{requester})."</code>\n";
+ $msg .= "Request was from <code>".html_escape(encode_utf8_safely($param{requester}))."</code>\n";
}
if (length $param{request_addr}) {
- $msg .= "to <code>".html_escape($param{request_addr})."</code>";
+ $msg .= "to <code>".html_escape(encode_utf8_safely($param{request_addr}))."</code>";
}
if (length $param{desc}) {
- $msg .= ":<br>\n$param{desc}\n";
+ $msg .= ":<br>\n".encode_utf8_safely($param{desc})."\n";
}
else {
$msg .= ".\n";
$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})),
};
}
}
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!";
}
}
}
- if (not __check_limit(data => \@data,
+ if (not check_limit(data => \@data,
exists $param{limit}?(limit => $param{limit}):(),
transcript => $transcript,
)) {
}
-=head2 __check_limit
+=head2 check_limit
- __check_limit(data => \@data, limit => $param{limit});
+ check_limit(data => \@data, limit => $param{limit});
Checks to make sure that bugs match any limits; each entry of @data
=cut
-sub __check_limit{
+sub check_limit{
my %param = validate_with(params => \@_,
- spec => {data => {type => ARRAYREF|SCALAR,
+ spec => {data => {type => ARRAYREF|HASHREF,
},
limit => {type => HASHREF|UNDEF,
},
}
if (not $match) {
$going_to_fail = 1;
- print {$transcript} qq($field: ).join(', ',map{qq("$_")} make_list($data->{$field})).
+ print {$transcript} qq($field: ').join(', ',map{qq("$_")} make_list($data->{$field})).
"' does not match at least one of ".
join(', ',map {ref($_)?'(regex)':qq("$_")} make_list($param{limit}{$field}))."\n";
}
$extra_var ||={};
my $hole_var = {'&bugurl' =>
sub{"$_[0]: ".
- 'http://'.$config{cgi_domain}.'/'.
- Debbugs::CGI::bug_url($_[0]);
+ $config{cgi_domain}.'/'.
+ Debbugs::CGI::bug_links(bug => $_[0],
+ links_only => 1,
+ );
}
};