user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH] Import.pm: Deal with potentially missing From and Sender headers
@ 2018-07-19 19:36 Eric W. Biederman
  2018-07-19 20:44 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Eric W. Biederman @ 2018-07-19 19:36 UTC (permalink / raw)
  To: Eric Wong; +Cc: meta


Use ||= '' to ensure that if the From or Sender header is not present
the code sees an empty string and instead of undefined.

I had some email messages with a From field without an @ (because the
sender was local) and without a Sender which were causing errors when
imported.  I think this was bad enough that the email messages were
failing to be imported.

Signed-off-by: Eric Biederamn <ebiederm@xmission.com>
---
 lib/PublicInbox/Import.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index f320c58c6b57..4e3b4c551797 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -278,10 +278,12 @@ sub extract_author_info ($) {
 
 	my $sender = '';
 	my $from = $mime->header('From');
+	$from ||= '';
 	my ($email) = PublicInbox::Address::emails($from);
 	my ($name) = PublicInbox::Address::names($from);
 	if (!defined($name) || !defined($email)) {
 		$sender = $mime->header('Sender');
+		$sender ||= '';
 		if (!defined($name)) {
 			($name) = PublicInbox::Address::names($sender);
 		}
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Import.pm: Deal with potentially missing From and Sender headers
  2018-07-19 19:36 [PATCH] Import.pm: Deal with potentially missing From and Sender headers Eric W. Biederman
@ 2018-07-19 20:44 ` Eric Wong
  2018-07-19 20:48   ` Eric W. Biederman
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Wong @ 2018-07-19 20:44 UTC (permalink / raw)
  To: Eric W. Biederman; +Cc: meta

"Eric W. Biederman" <ebiederm@xmission.com> wrote:
> 
> Use ||= '' to ensure that if the From or Sender header is not present
> the code sees an empty string and instead of undefined.
> 
> I had some email messages with a From field without an @ (because the
> sender was local) and without a Sender which were causing errors when
> imported.  I think this was bad enough that the email messages were
> failing to be imported.

Thanks, pushed to master as ce5af2029b6bc703f3d8cf7bb5c68732c41f210e.

I assume this is from testing against personal mail?
I haven't tried that, yet :x

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Import.pm: Deal with potentially missing From and Sender headers
  2018-07-19 20:44 ` Eric Wong
@ 2018-07-19 20:48   ` Eric W. Biederman
  0 siblings, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2018-07-19 20:48 UTC (permalink / raw)
  To: Eric Wong; +Cc: meta

Eric Wong <e@80x24.org> writes:

> "Eric W. Biederman" <ebiederm@xmission.com> wrote:
>> 
>> Use ||= '' to ensure that if the From or Sender header is not present
>> the code sees an empty string and instead of undefined.
>> 
>> I had some email messages with a From field without an @ (because the
>> sender was local) and without a Sender which were causing errors when
>> imported.  I think this was bad enough that the email messages were
>> failing to be imported.
>
> Thanks, pushed to master as ce5af2029b6bc703f3d8cf7bb5c68732c41f210e.
>
> I assume this is from testing against personal mail?
> I haven't tried that, yet :x

It is.  So far just importing my personal mail.

Eric


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-19 20:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-19 19:36 [PATCH] Import.pm: Deal with potentially missing From and Sender headers Eric W. Biederman
2018-07-19 20:44 ` Eric Wong
2018-07-19 20:48   ` Eric W. Biederman

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).