From f81ad477cb013d05b9b11fa051a9ebc5983a5be6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 21 Sep 2015 11:11:12 +0000 Subject: nntp: proper UTF-8 support (hopefully?) 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(-) (limited to 'lib/PublicInbox/NNTP.pm') diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 2b580d16..91b10f20 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}); -- cgit v1.2.3-24-ge0c7