* [PATCH] import: fix encoding issues from weird "raw" emails
@ 2017-06-20 23:03 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2017-06-20 23:03 UTC (permalink / raw)
To: meta
This seems to allow weirdly-encoded "raw" emails in
blade.nagaokaut.ac.jp/ruby/ruby-core/*
to be handled without difficulties.
---
lib/PublicInbox/Import.pm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 65da4dd..31dc769 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;
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-06-20 23:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-20 23:03 [PATCH] import: fix encoding issues from weird "raw" emails Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).