From 584721cf9c98beabce9b779faafa1eabb5c24de6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 26 Oct 2021 10:35:51 +0000 Subject: eml: keep body if no headers are found This easily allows us to treat "git diff" output as header-less "messages" for commands such as "lei p2q". --- lib/PublicInbox/Eml.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm index 3c681ba5..485f637a 100644 --- a/lib/PublicInbox/Eml.pm +++ b/lib/PublicInbox/Eml.pm @@ -122,9 +122,10 @@ sub new { my $hdr = substr($$ref, 0, $header_size_limit + 1); hdr_truncate($hdr) if length($hdr) > $header_size_limit; bless { hdr => \$hdr, crlf => $1 }, __PACKAGE__; - } else { # nothing useful - my $hdr = $$ref = ''; - bless { hdr => \$hdr, crlf => "\n" }, __PACKAGE__; + } else { # just a body w/o header? + my $hdr = ''; + my $eol = ($$ref =~ /(\r?\n)/) ? $1 : "\n"; + bless { hdr => \$hdr, crlf => $eol, bdy => $ref }, __PACKAGE__; } } -- cgit v1.2.3-24-ge0c7