]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: ensure body lines end with CRLF
authorEric Wong <e@80x24.org>
Tue, 22 Sep 2015 10:09:44 +0000 (10:09 +0000)
committerEric Wong <e@80x24.org>
Tue, 22 Sep 2015 22:12:17 +0000 (22:12 +0000)
It's common for mail bodies to end with LF-only, so end them with
CRLF to avoid triggering errors in clients.

lib/PublicInbox/NNTP.pm

index bc8d6eda63b972b781ce2e05b897e4c38be294a8..71b774d224bc03396e2ec582448fb6cddac36e76 100644 (file)
@@ -393,7 +393,9 @@ sub simple_body_write ($$) {
        my $body = $s->body;
        $s->body_set('');
        $body =~ s/^\./../smg;
+       $body =~ s/(?<!\r)\n/\r\n/sg;
        do_more($self, $body);
+       do_more($self, "\r\n") unless $body =~ /\r\n\z/s;
        '.'
 }