user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 7/8] lei_input: drop "From " line on single "eml" (message/rfc822)
  2021-03-22  7:53  6% [PATCH 0/8] lei input handling improvements Eric Wong
@ 2021-03-22  7:54  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-03-22  7:54 UTC (permalink / raw)
  To: meta

This matches the long-standing behavior of public-inbox-mda,
public-inbox-learn and our other tools.  It is useful because
mutt, "git format-patch", and likely other tools will
pipe a single message with a "From " header line, but with
no further "From " escaping or Content-Length: header.
---
 lib/PublicInbox/LeiInput.pm |  4 ++++
 t/lei-import.t              | 10 ++++++++++
 2 files changed, 14 insertions(+)

diff --git a/lib/PublicInbox/LeiInput.pm b/lib/PublicInbox/LeiInput.pm
index c62b0893..859fdb11 100644
--- a/lib/PublicInbox/LeiInput.pm
+++ b/lib/PublicInbox/LeiInput.pm
@@ -32,6 +32,10 @@ sub input_fh {
 			return $self->{lei}->child_error(1 << 8, <<"");
 error reading $name: $!
 
+		# mutt pipes single RFC822 messages with a "From " line,
+		# but no Content-Length or "From " escaping.
+		# "git format-patch" also generates such files by default.
+		$buf =~ s/\A[\r\n]*From [^\r\n]*\r?\n//s;
 		$self->eml_cb(PublicInbox::Eml->new(\$buf), @args);
 	} else {
 		# prepare_inputs already validated $ifmt
diff --git a/t/lei-import.t b/t/lei-import.t
index e0b517f4..eef1e4e2 100644
--- a/t/lei-import.t
+++ b/t/lei-import.t
@@ -29,6 +29,16 @@ lei_ok(qw(q s:boolean -f mboxrd), \'blob accessible after import');
 lei_ok(qw(import -F eml), 't/data/message_embed.eml',
 	\'import single file by path');
 
+lei_ok(qw(q m:testmessage@example.com));
+is($lei_out, "[null]\n", 'no results, yet');
+my $oid = '9bf1002c49eb075df47247b74d69bcd555e23422';
+my $eml = eml_load('t/utf8.eml');
+my $in = 'From x@y Fri Oct  2 00:00:00 1993'."\n".$eml->as_string;
+lei_ok([qw(import -F eml -)], undef, { %$lei_opt, 0 => \$in });
+lei_ok(qw(q m:testmessage@example.com));
+is(json_utf8->decode($lei_out)->[0]->{'blob'}, $oid,
+	'got expected OID w/o From');
+
 my $str = <<'';
 From: a@b
 Message-ID: <x@y>

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/8] lei input handling improvements
@ 2021-03-22  7:53  6% Eric Wong
  2021-03-22  7:54  7% ` [PATCH 7/8] lei_input: drop "From " line on single "eml" (message/rfc822) Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-03-22  7:53 UTC (permalink / raw)
  To: meta

lei <convert|import> share a bit more code, now; and being
able to set "-c imap.debug" on the command-line should make
future work easier.

All this should set us up nicely for implementing "lei mark"
to add/remove keywords and labels.

Eric Wong (8):
  lei: support -c <name>=<value> to overrides
  net_reader: escape nasty chars from Net::NNTP->message
  lei: share input code between convert and import
  lei: simplify workers_start and callers
  mbox_reader: add ->reads method to avoid nonsensical formats
  lei_input: common filehandle reader for eml + mbox
  lei_input: drop "From " line on single "eml" (message/rfc822)
  lei import: ignore Status headers in "eml" messages

 MANIFEST                         |   1 +
 lib/PublicInbox/InboxWritable.pm |   2 +-
 lib/PublicInbox/LEI.pm           | 137 ++++++++++++++++++-------------
 lib/PublicInbox/LeiConvert.pm    |  94 ++++-----------------
 lib/PublicInbox/LeiExternal.pm   |   2 +-
 lib/PublicInbox/LeiImport.pm     | 107 +++++-------------------
 lib/PublicInbox/LeiInput.pm      | 106 ++++++++++++++++++++++++
 lib/PublicInbox/LeiP2q.pm        |   4 +-
 lib/PublicInbox/MboxReader.pm    |   5 ++
 lib/PublicInbox/NetReader.pm     |  10 ++-
 t/lei-import.t                   |  37 +++++++--
 t/lei.t                          |   9 ++
 12 files changed, 278 insertions(+), 236 deletions(-)
 create mode 100644 lib/PublicInbox/LeiInput.pm

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-03-22  7:53  6% [PATCH 0/8] lei input handling improvements Eric Wong
2021-03-22  7:54  7% ` [PATCH 7/8] lei_input: drop "From " line on single "eml" (message/rfc822) 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).