X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FMailDiff.pm;h=7511144c6419e235e7b2e63f5a81f64fa3fed6a0;hb=refs%2Fheads%2Fmaster;hp=0ed06f9a25269350a30c268deaaa2ba67fe79d06;hpb=20ab293a131f0ec228932bf3448d1b09e280672b;p=public-inbox.git diff --git a/lib/PublicInbox/MailDiff.pm b/lib/PublicInbox/MailDiff.pm index 0ed06f9a..7511144c 100644 --- a/lib/PublicInbox/MailDiff.pm +++ b/lib/PublicInbox/MailDiff.pm @@ -4,8 +4,6 @@ package PublicInbox::MailDiff; use v5.12; use File::Temp 0.19 (); # 0.19 for ->newdir use PublicInbox::ContentHash qw(content_digest); -use PublicInbox::ContentDigestDbg; -use Data::Dumper (); use PublicInbox::MsgIter qw(msg_part_text); use PublicInbox::ViewDiff qw(flush_diff); use PublicInbox::GitAsyncCat; @@ -21,8 +19,10 @@ sub write_part { # Eml->each_part callback my $ct = $part->content_type || 'text/plain'; my ($s, $err) = msg_part_text($part, $ct); my $sfx = defined($s) ? 'txt' : 'bin'; - open my $fh, '>', "$self->{curdir}/$idx.$sfx" or die "open: $!"; - print $fh ($s // $part->body) or die "print $!"; + $s //= $part->body; + $s =~ s/\r+\n/\n/sg; + open my $fh, '>:utf8', "$self->{curdir}/$idx.$sfx" or die "open: $!"; + print $fh $s or die "print $!"; close $fh or die "close $!"; } @@ -34,12 +34,11 @@ sub dump_eml ($$$) { $eml->each_part(\&write_part, $self); return if $self->{ctx}; # don't need content_digest noise in WWW UI + require PublicInbox::ContentDigestDbg; # XXX is this even useful? perhaps hide it behind a CLI switch open my $fh, '>', "$dir/content_digest" or die "open: $!"; my $dig = PublicInbox::ContentDigestDbg->new($fh); - local $Data::Dumper::Useqq = 1; - local $Data::Dumper::Terse = 1; content_digest($eml, $dig); print $fh "\n", $dig->hexdigest, "\n" or die "print $!"; close $fh or die "close: $!"; @@ -69,9 +68,9 @@ sub next_smsg ($) { sub emit_msg_diff { my ($bref, $self) = @_; # bref is `git diff' output # will be escaped to `•' in HTML + utf8::decode($$bref); $self->{ctx}->{ibx}->{obfuscate} and obfuscate_addrs($self->{ctx}->{ibx}, $$bref, "\x{2022}"); - $$bref =~ s/\r+\n/\n/sg; print { $self->{ctx}->{zfh} } '
' if $self->{nr} > 1;
 	flush_diff($self->{ctx}, $bref);
 	next_smsg($self);