diff options
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 524784cb..603cf094 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -15,7 +15,7 @@ use PublicInbox::MID qw(mid_escape $MID_EXTRACT); use PublicInbox::Eml; use POSIX qw(strftime); use PublicInbox::DS qw(now); -use Digest::SHA qw(sha1_hex); +use PublicInbox::SHA qw(sha1_hex); use Time::Local qw(timegm timelocal); use PublicInbox::GitAsyncCat; use PublicInbox::Address; @@ -72,9 +72,8 @@ sub process_line ($$) { my $res = eval { $req->($self, @args) }; my $err = $@; if ($err && $self->{sock}) { - local $/ = "\n"; - chomp($l); - err($self, 'error from: %s (%s)', $l, $err); + $l =~ s/\r?\n//s; + warn("error from: $l ($err)\n"); $res = \"503 program fault - command not performed\r\n"; } defined($res) ? $self->write($res) : 0; @@ -189,7 +188,7 @@ sub listgroup_range_i { my ($self, $beg, $end) = @_; my $r = $self->{ibx}->mm(1)->msg_range($beg, $end, 'num'); scalar(@$r) or return; - $self->msg_more(join("\r\n", @$r, '')); + $self->msg_more(join('', map { "$_->[0]\r\n" } @$r)); 1; } @@ -524,8 +523,7 @@ sub msg_hdr_write ($$) { set_nntp_headers($eml, $smsg); my $hdr = $eml->{hdr} // \(my $x = ''); - # fixup old bug from import (pre-a0c07cba0e5d8b6a) - $$hdr =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s; + PublicInbox::Eml::strip_from($$hdr); $$hdr =~ s/(?<!\r)\n/\r\n/sg; # Alpine barfs without this # for leafnode compatibility, we need to ensure Message-ID headers @@ -538,7 +536,11 @@ sub blob_cb { # called by git->cat_async via ibx_async_cat my ($bref, $oid, $type, $size, $smsg) = @_; my $self = $smsg->{nntp}; my $code = $smsg->{nntp_code}; - if (!defined($oid)) { + if (!defined($type)) { + warn "E: git aborted on $oid / $smsg->{blob} ". + $self->{-ibx}->{inboxdir}; + return $self->close; + } elsif ($type ne 'blob') { # it's possible to have TOCTOU if an admin runs # public-inbox-(edit|purge), just move onto the next message warn "E: $smsg->{blob} missing in $smsg->{-ibx}->{inboxdir}\n"; @@ -945,11 +947,6 @@ sub cmd_xpath ($$) { '223 '.join(' ', sort(@paths))."\r\n"; } -sub err ($$;@) { - my ($self, $fmt, @args) = @_; - printf { $self->{nntpd}->{err} } $fmt."\n", @args; -} - sub out ($$;@) { my ($self, $fmt, @args) = @_; printf { $self->{nntpd}->{out} } $fmt."\n", @args; @@ -958,7 +955,7 @@ sub out ($$;@) { # callback used by PublicInbox::DS for any (e)poll (in/out/hup/err) sub event_step { my ($self) = @_; - + local $SIG{__WARN__} = $self->{nntpd}->{warn_cb}; return unless $self->flush_write && $self->{sock} && !$self->{long_cb}; # only read more requests if we've drained the write buffer, |