From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 101E820105 for ; Mon, 21 Sep 2015 11:11:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 6/6] nntp: proper UTF-8 support (hopefully?) Date: Mon, 21 Sep 2015 11:11:12 +0000 Message-Id: <20150921111112.18873-7-e@80x24.org> In-Reply-To: <20150921111112.18873-1-e@80x24.org> References: <20150921111112.18873-1-e@80x24.org> List-Id: RFC 3977 stipulates the use of UTF-8 as the default charset, so we shall try using that and hopefully not mangle things. --- lib/PublicInbox/NNTP.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 2b580d1..91b10f2 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -8,7 +8,7 @@ use fields qw(nntpd article rbuf ng long_res); use PublicInbox::Msgmap; use PublicInbox::GitCatFile; use PublicInbox::MID qw(mid2path); -use Email::Simple; +use Email::MIME; use Data::Dumper qw(Dumper); use POSIX qw(strftime); use Time::HiRes qw(clock_gettime ualarm CLOCK_MONOTONIC); @@ -29,6 +29,7 @@ my %DISABLED; # = map { $_ => 1 } qw(xover list_overview_fmt newnews xhdr); sub new ($$$) { my ($class, $sock, $nntpd) = @_; my $self = fields::new($class); + binmode $sock, ':utf8'; # RFC 3977 $self->SUPER::new($sock); $self->{nntpd} = $nntpd; res($self, '201 server ready - post via email'); @@ -367,7 +368,7 @@ find_mid: found: my $o = 'HEAD:' . mid2path($mid); my $bytes; - my $s = eval { Email::Simple->new($ng->gcf->cat_file($o, \$bytes)) }; + my $s = eval { Email::MIME->new($ng->gcf->cat_file($o, \$bytes)) }; return $err unless $s; if ($set_headers) { $s->header_set('Newsgroups', $ng->{name}); -- EW