* [PATCH 3/9] eml: keep body if no headers are found
2021-10-26 10:35 4% [PATCH 0/9] lei p2q: more capable than originally thought Eric Wong
@ 2021-10-26 10:35 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-10-26 10:35 UTC (permalink / raw)
To: meta
This easily allows us to treat "git diff" output as header-less
"messages" for commands such as "lei p2q".
---
lib/PublicInbox/Eml.pm | 7 ++++---
t/eml.t | 11 +++++++++++
t/mbox_reader.t | 6 +++++-
3 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/lib/PublicInbox/Eml.pm b/lib/PublicInbox/Eml.pm
index 3c681ba5bc2e..485f637a3e7b 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__;
}
}
diff --git a/t/eml.t b/t/eml.t
index 0cf48f225a45..2d8993a51075 100644
--- a/t/eml.t
+++ b/t/eml.t
@@ -216,6 +216,17 @@ if ('one newline before headers') {
is($eml->body, "");
}
+if ('body only') {
+ my $str = <<EOM;
+--- a/lib/PublicInbox/Eml.pm
++++ b/lib/PublicInbox/Eml.pm
+@@ -122,9 +122,10 @@ sub new {
+\x20
+EOM
+ my $eml = PublicInbox::Eml->new($str);
+ is($eml->body, $str, 'body-only accepted');
+}
+
for my $cls (@classes) { # XXX: matching E::M, but not sure about this
my $s = <<EOF;
Content-Type: multipart/mixed; boundary="b"
diff --git a/t/mbox_reader.t b/t/mbox_reader.t
index e5f57d7bcba3..87e8f397662c 100644
--- a/t/mbox_reader.t
+++ b/t/mbox_reader.t
@@ -138,7 +138,11 @@ EOM
PublicInbox::MboxReader->$m($fh, sub {
push @x, $_[0]->as_string
});
- is_deeply(\@x, [], "messages in invalid $m");
+ if ($m =~ /\Amboxcl/) {
+ is_deeply(\@x, [], "messages in invalid $m");
+ } else {
+ is_deeply(\@x, [ "\n$html" ], "body-only $m");
+ }
is_deeply([grep(!/^W: leftover/, @w)], [],
"no extra warnings besides leftover ($m)");
}
^ permalink raw reply related [relevance 7%]
* [PATCH 0/9] lei p2q: more capable than originally thought
@ 2021-10-26 10:35 4% Eric Wong
2021-10-26 10:35 7% ` [PATCH 3/9] eml: keep body if no headers are found Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-10-26 10:35 UTC (permalink / raw)
To: meta
I started writing documentation and managed to cobble up a p2q
example in patch 7/9 to find unapplied patches when combined
with "git log". 7/9 makes p2q use less memory, now.
Fixed a bunch of small bugs along the way and killed some
redundant code, too.
Eric Wong (9):
doc: tuning: additional notes for many inboxes
doc: lei-store-format: mail sync section, update IPC
eml: keep body if no headers are found
lei q: enable expensive Xapian flags
lei inspect: fix atfork hook
lei: add net getopt spec to various commands
lei p2q: use LeiInput for multi-patch series
lei rm|tag: drop redundant mbox+net callbacks
input_pipe: account for undefined {sock}
Documentation/lei-p2q.pod | 6 ++
Documentation/lei-store-format.pod | 14 +++-
Documentation/public-inbox-tuning.pod | 11 ++-
lib/PublicInbox/Eml.pm | 7 +-
lib/PublicInbox/InputPipe.pm | 2 +-
lib/PublicInbox/LEI.pm | 11 +--
lib/PublicInbox/LeiInput.pm | 30 +++++--
lib/PublicInbox/LeiInspect.pm | 2 +-
lib/PublicInbox/LeiP2q.pm | 115 +++++++++++++-------------
lib/PublicInbox/LeiRm.pm | 10 ---
lib/PublicInbox/LeiSearch.pm | 2 +
lib/PublicInbox/LeiTag.pm | 11 ---
t/eml.t | 11 +++
t/mbox_reader.t | 6 +-
14 files changed, 134 insertions(+), 104 deletions(-)
^ permalink raw reply [relevance 4%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-10-26 10:35 4% [PATCH 0/9] lei p2q: more capable than originally thought Eric Wong
2021-10-26 10:35 7% ` [PATCH 3/9] eml: keep body if no headers are found Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).