}
use Debbugs::Config qw(:config);
-use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions);
+use Debbugs::Common qw(:lock buglog :misc get_hashname sort_versions :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 Storable qw(dclone nfreeze);
use List::Util qw(first max);
+use Encode qw(encode_utf8);
use Carp;
for my $data (@data) {
my $old_data = dclone($data);
my $hash = get_hashname($data->{bug_num});
- my $report_fh = IO::File->new("db-h/$hash/$data->{bug_num}.report",'r') or
- die "Unable to open original report db-h/$hash/$data->{bug_num}.report for reading: $!";
+ my $report_fh = IO::File->new("$config{spool_dir}/db-h/$hash/$data->{bug_num}.report",'r') or
+ die "Unable to open original report $config{spool_dir}/db-h/$hash/$data->{bug_num}.report for reading: $!";
my $orig_report;
{
local $/;
headers =>
[To => $data->{submitter},
Subject => "$config{ubug}#$data->{bug_num} ".
- "closed by $param{requester} ($param{request_subject})",
+ "closed by $param{requester} ".(defined $param{request_subject}?"($param{request_subject})":""),
],
)
],
croak "Did not alter merged bugs";
}
}
- my ($change_bug) = keys %{$changes};
- $bug_changed{$change_bug}++;
- print {$transcript} __bug_info($data{$change_bug}) if
- $param{show_bug_info} and not __internal_request(1);
- $bug_info_shown{$change_bug} = 1;
- __allow_relocking($param{locks},[keys %data]);
- 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};
- set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug},
- block => $change->{field} eq 'blocks' ? $change->{bug} : $key,
- remove => 1,
- hash_slice(%param,
- keys %common_options,
- keys %append_action_options),
- );
+ my @bugs_to_change = keys %{$changes};
+ for my $change_bug (@bugs_to_change) {
+ next unless exists $changes->{$change_bug};
+ $bug_changed{$change_bug}++;
+ print {$transcript} __bug_info($data{$change_bug}) if
+ $param{show_bug_info} and not __internal_request(1);
+ $bug_info_shown{$change_bug} = 1;
+ __allow_relocking($param{locks},[keys %data]);
+ 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};
+ set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug},
+ block => $change->{field} eq 'blocks' ? $change->{bug} : $key,
+ remove => 1,
+ hash_slice(%param,
+ keys %common_options,
+ keys %append_action_options),
+ );
+ }
+ for my $key (keys %unhandled_targets) {
+ set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug},
+ block => $change->{field} eq 'blocks' ? $change->{bug} : $key,
+ add => 1,
+ hash_slice(%param,
+ keys %common_options,
+ keys %append_action_options),
+ );
+ }
}
- for my $key (keys %unhandled_targets) {
- set_blocks(bug => $change->{field} eq 'blocks' ? $key : $change->{bug},
- block => $change->{field} eq 'blocks' ? $change->{bug} : $key,
- add => 1,
- hash_slice(%param,
- keys %common_options,
- keys %append_action_options),
- );
+ else {
+ $change->{function}->(bug => $change->{bug},
+ $change->{key}, $change->{func_value},
+ exists $change->{options}?@{$change->{options}}:(),
+ hash_slice(%param,
+ keys %common_options,
+ keys %append_action_options),
+ );
}
}
- else {
- $change->{function}->(bug => $change->{bug},
- $change->{key}, $change->{func_value},
- exists $change->{options}?@{$change->{options}}:(),
- hash_slice(%param,
- keys %common_options,
- keys %append_action_options),
- );
- }
+ __disallow_relocking($param{locks});
+ my ($data,$n_locks) =
+ __lock_and_load_merged_bugs(bugs_to_load => [keys %merging],
+ data => \@data,
+ locks => $param{locks},
+ debug => $debug,
+ reload_all => 1,
+ );
+ $new_locks += $n_locks;
+ $locks += $n_locks;
+ %data = %{$data};
+ @data = values %data;
+ ($merge_status,$bugs_to_merge) =
+ __calculate_merge_status(\@data,\%data,$param{bug},$merge_status);
+ ($disallowed_changes,$changes) =
+ __calculate_merge_changes(\@data,$merge_status,\%param);
+ $attempts = max(values %bug_changed);
}
- __disallow_relocking($param{locks});
- my ($data,$n_locks) =
- __lock_and_load_merged_bugs(bugs_to_load => [keys %merging],
- data => \@data,
- locks => $param{locks},
- debug => $debug,
- reload_all => 1,
- );
- $new_locks += $n_locks;
- $locks += $n_locks;
- %data = %{$data};
- @data = values %data;
- ($merge_status,$bugs_to_merge) =
- __calculate_merge_status(\@data,\%data,$param{bug},$merge_status);
- ($disallowed_changes,$changes) =
- __calculate_merge_changes(\@data,$merge_status,\%param);
- $attempts = max(values %bug_changed);
}
if ($param{show_bug_info} and not __internal_request(1)) {
for my $data (sort {$a->{bug_num} <=> $b->{bug_num}} @data) {
for my $bug (split ' ', $data->{blocks}) {
for my $new_bug (@new_bugs) {
set_blocks(bug => $new_bug,
- blocks => $bug,
+ block => $bug,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
for my $bug (split ' ', $data->{blockedby}) {
for my $new_bug (@new_bugs) {
set_blocks(bug => $bug,
- blocks => $new_bug,
+ block => $new_bug,
hash_slice(%param,
keys %common_options,
keys %append_action_options),
$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($param{command}))." -->\n":""
),
(length $param{requester} ?
- "<!-- requester: ".html_escape($param{requester})." -->\n":""
+ "<!-- requester: ".html_escape(encode_utf8($param{requester}))." -->\n":""
),
(length $param{request_addr} ?
- "<!-- request_addr: ".html_escape($param{request_addr})." -->\n":""
+ "<!-- request_addr: ".html_escape(encode_utf8($param{request_addr}))." -->\n":""
),
"<!-- time:".time()." -->\n",
$data_diff,
- "<strong>".html_escape($param{action})."</strong>\n");
+ "<strong>".html_escape(encode_utf8($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($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($param{request_addr}))."</code>";
}
if (length $param{desc}) {
- $msg .= ":<br>\n$param{desc}\n";
+ $msg .= ":<br>\n".encode_utf8($param{desc})."\n";
}
else {
$msg .= ".\n";