about summary refs log tree commit homepage
path: root/lib/PublicInbox/NNTP.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-13 20:46:52 +0000
committerEric Wong <e@80x24.org>2019-06-13 20:47:16 +0000
commit4b8b3036ba08515eb66fb014b6ded9dc57e079b2 (patch)
tree8b09dab24c8f2b496cbcbae9976280fa2b23631a /lib/PublicInbox/NNTP.pm
parentafb62cec9097de884bee427093219d598561474d (diff)
downloadpublic-inbox-4b8b3036ba08515eb66fb014b6ded9dc57e079b2.tar.gz
Leafnode cannot handle Message-ID headers which are too long and
require folding via Email::Simple::Header.  Since there are
already many of these messages in git with the header already
folded, we need to handle the unfolding when emitting the
message via NNTP.

As far as we know, Leafnode is the only client software
incapable of handling this case.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r--lib/PublicInbox/NNTP.pm7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 1d07220d..d409e782 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -519,6 +519,13 @@ sub _header ($) {
         my $hdr = $_[0]->header_obj->as_string;
         utf8::encode($hdr);
         $hdr =~ s/(?<!\r)\n/\r\n/sg;
+
+        # for leafnode compatibility, we need to ensure Message-ID headers
+        # are only a single line.  We can't subclass Email::Simple::Header
+        # and override _default_fold_at in here, either; since that won't
+        # affect messages already in the archive.
+        $hdr =~ s/^(Message-ID:)[ \t]*\r\n[ \t]+([^\r]+)\r\n/$1 $2\r\n/igsm;
+
         $hdr
 }