about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-06-20 22:06:54 +0000
committerEric Wong <e@80x24.org>2017-06-20 22:06:54 +0000
commit3ef89f98a662a135ae18dddf3ff3e61e8e3ca996 (patch)
tree09f07e4c038e26d51c90db6338e5c083f1b2bf69 /lib
parentef9ce6f2dfc9fcbb91e3cec0b7a2b7f7e359be5d (diff)
downloadpublic-inbox-3ef89f98a662a135ae18dddf3ff3e61e8e3ca996.tar.gz
This seems to allow weirdly-encoded "raw" emails in
  blade.nagaokaut.ac.jp/ruby/ruby-core/*
to be handled without difficulties.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Import.pm9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 65da4ddf..31dc7695 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -54,6 +54,8 @@ sub gfi_start {
         $self->{lockfh} = $lockfh;
         $self->{pid} = $pid;
         $self->{nchg} = 0;
+        binmode $out_w, ':raw' or die "binmode :raw failed: $!";
+        binmode $in_r, ':raw' or die "binmode :raw failed: $!";
         ($in_r, $out_w);
 }
 
@@ -187,13 +189,14 @@ sub add {
                 print $w "reset $ref\n" or wfail;
         }
 
+        utf8::encode($email);
+        utf8::encode($name);
+        utf8::encode($subject);
         # quiet down wide character warnings:
-        binmode $w, ':utf8' or die "binmode :utf8 failed: $!";
         print $w "commit $ref\nmark :$commit\n",
                 "author $name <$email> $date\n",
                 "committer $self->{ident} ", now2822(), "\n" or wfail;
-        binmode $w, ':raw' or die "binmode :raw failed: $!";
-        print $w "data ", (bytes::length($subject) + 1), "\n",
+        print $w "data ", (length($subject) + 1), "\n",
                 $subject, "\n\n" or wfail;
         if ($tip ne '') {
                 print $w 'from ', ($parent ? $parent : $tip), "\n" or wfail;