user/dev discussion of public-inbox itself
 help / Atom feed
* [PATCH] Import.pm: Deal with potentially missing From and Sender headers
@ 2018-07-19 19:36 ebiederm
  2018-07-19 20:44 ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: ebiederm @ 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	[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 ebiederm
@ 2018-07-19 20:44 ` Eric Wong
  2018-07-19 20:48   ` ebiederm
  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   ` ebiederm
  0 siblings, 0 replies; 3+ messages in thread
From: ebiederm @ 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, back to index

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 ebiederm
2018-07-19 20:44 ` Eric Wong
2018-07-19 20:48   ` ebiederm

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.org/gmane.mail.public-inbox.general

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox