From: Don Armstrong Date: Thu, 14 Mar 2013 21:23:05 +0000 (-0700) Subject: Merge remote-tracking branch 'origin/don/fix_encoding' X-Git-Tag: release/2.6.0~308^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=759eb8a67ce40a4b881cc058c25a747e851669b7;hp=8aa06c2056c07cb7a6a25bfbf388fef658ad7208;p=debbugs.git Merge remote-tracking branch 'origin/don/fix_encoding' --- diff --git a/Debbugs/Log.pm b/Debbugs/Log.pm index 8b99b7d..551fd39 100644 --- a/Debbugs/Log.pm +++ b/Debbugs/Log.pm @@ -405,6 +405,15 @@ sub write_log_records if (defined $recips) { croak "recips not undef or array" unless ref($recips) eq 'ARRAY'; + my $wrong_encoding = 0; + my @recips = + map { if (is_utf8($_)) { + $wrong_encoding=1; + encode_utf8($_); + } else { + $_; + }} @$recips; + carp('Recipients was in the wrong encoding (perl internal instead of utf8 octets') if $wrong_encoding; print {$logfh} join("\04", @$recips) . "\n" or die "Unable to write to logfile: $!"; } else { diff --git a/Debbugs/Status.pm b/Debbugs/Status.pm index 7d72c03..c66ab41 100644 --- a/Debbugs/Status.pm +++ b/Debbugs/Status.pm @@ -1615,6 +1615,7 @@ sub update_realtime { my $idx_new = IO::File->new($file.'.new','w') or die "Couldn't open ${file}.new: $!"; + binmode($idx_new,':raw:encoding(UTF-8)'); my $min_bug = min(keys %bugs); my $line; my @line; diff --git a/scripts/gen-indices b/scripts/gen-indices index 0fe8ea8..7a8670d 100755 --- a/scripts/gen-indices +++ b/scripts/gen-indices @@ -83,6 +83,7 @@ use Debbugs::Config qw(:config); use Debbugs::Common qw(getparsedaddrs getbugcomponent lockpid); use Debbugs::Status qw(readbug split_status_fields); use Debbugs::Log; +use Debbugs::UTF8 qw(encode_utf8_structure); chdir($config{spool_dir}) or die "chdir $config{spool_dir} failed: $!"; @@ -198,7 +199,7 @@ while (my $dir = shift @dirs) { next; } next if $stat->mtime < $time; - my $fdata = split_status_fields(readbug($bug, $initialdir)); + my ($fdata) = encode_utf8_structure(split_status_fields(readbug($bug, $initialdir))); $modification_made = 1; addbugtoindex("package", $bug, make_list($fdata->{package})); addbugtoindex("tag", $bug, make_list($fdata->{keywords})); diff --git a/scripts/process b/scripts/process index 73eebb0..17aa15b 100755 --- a/scripts/process +++ b/scripts/process @@ -1207,7 +1207,7 @@ sub sendmessage { write_log_records(logfh => $logfh, records => {text => stripbccs($msg), type => 'recips', - recips => [@{$recips}], + recips => [map {encode_utf8($_)} @{$recips}], }, ); if (ref($bcc)) { diff --git a/t/13_utf8_mail.t b/t/13_utf8_mail.t index 4eda888..d5397dc 100644 --- a/t/13_utf8_mail.t +++ b/t/13_utf8_mail.t @@ -53,7 +53,7 @@ END{ send_message(to=>'submit@bugs.something', headers => [To => 'submit@bugs.something', - From => 'foo@bugs.something', + From => 'foöff@bugs.something', Subject => 'Submiting a bug', ], body => < [{Type=>"text/plain",Charset=>"utf-8",Data=><