]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: proper UTF-8 support (hopefully?)
authorEric Wong <e@80x24.org>
Mon, 21 Sep 2015 11:11:12 +0000 (11:11 +0000)
committerEric Wong <e@80x24.org>
Mon, 21 Sep 2015 11:37:33 +0000 (11:37 +0000)
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

index 2b580d16c03af3b3181c741ed2032f695a4a424a..91b10f20ac39894a561ecb313cc938a36b3e3c2b 100644 (file)
@@ -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});