9front - general discussion about 9front
 help / color / mirror / Atom feed
* upas/fs: header ignores
@ 2020-10-25  0:50 ori
  2020-10-25  1:07 ` [9front] " Kurt H Maier
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: ori @ 2020-10-25  0:50 UTC (permalink / raw)
  To: 9front

Now that the release is out, I'm going to
look at more email stuff. So, here's the
first bit of work, which does threee things:

- Remove /mail/lib/ignore, which filters
  the headers we show.
- Add /mail/lib/filterheaders, which has
  a new syntax: lines default to keep, but
  '!' can be used to drop a header:
- Add defaults.

The last time this came up, some people had
opinions on what reasonable defaults are,
so if you care, speak up.

Otherwise, the default behavior will be
unchanged from what we have today, since
I have no strong feelings on the matter.

diff -r 0281cd6caa8c sys/src/cmd/upas/fs/fs.c
--- a/sys/src/cmd/upas/fs/fs.c	Sat Oct 24 17:24:59 2020 -0700
+++ b/sys/src/cmd/upas/fs/fs.c	Sat Oct 24 17:46:15 2020 -0700
@@ -1500,11 +1500,31 @@
 typedef struct Ignorance Ignorance;
 struct Ignorance
 {
-	Ignorance *next;
+	int	drop;
+	int	len;
 	char	*str;
-	int	len;
 };
 static Ignorance *ignorance;
+static int nignorance;
+static Ignorance defaultignorance[] = {
+	{.drop=1, .len=13,	.str="Mime-Version:"},
+	{.drop=1, .len=8,	.str="Content-"},
+	{.drop=1, .len=11,	.str="Message-Id:"},
+	{.drop=1, .len=9,	.str="Received:"},
+	{.drop=1, .len=7,	.str="Mailer:"},
+	{.drop=1, .len=11,	.str="References:"},
+	{.drop=1, .len=11,	.str="Precedence:"},
+	{.drop=1, .len=2,	.str="X-"},
+	{.drop=1, .len=5,	.str="X400-"},
+	{.drop=1, .len=2,	.str="O-"},
+	{.drop=1, .len=5,	.str="List-"},
+	{.drop=1, .len=13,	.str="Organization:"},
+	{.drop=1, .len=11,	.str="User-Agent:"},
+	{.drop=1, .len=12,	.str="In-Reply-To:"},
+	{.drop=1, .len=13,	.str="Delivered-To:"},
+	{.drop=1, .len=20,	.str="DomainKey-Signature:"},
+	{.drop=1, .len=15,	.str="DKIM-Signature:"},
+};
 
 /*
  *  read the file of headers to ignore
@@ -1515,28 +1535,32 @@
 	char *p;
 	Ignorance *i;
 	Biobuf *b;
+	int drop;
 
 	if(ignorance != nil)
 		return;
 
-	b = Bopen("/mail/lib/ignore", OREAD);
-	if(b == 0)
+	b = Bopen("/mail/lib/filterheaders", OREAD);
+	if(b == nil){
+		ignorance = defaultignorance;
+		nignorance = nelem(defaultignorance);
 		return;
+	}
 	while(p = Brdline(b, '\n')){
 		p[Blinelen(b) - 1] = 0;
 		while(*p && (*p == ' ' || *p == '\t'))
 			p++;
-		if(*p == '#')
+		if(*p == '#' || *p == '\0')
 			continue;
-		i = emalloc(sizeof *i);
+		if(drop = (*p == '!'))
+			p++;
+		ignorance = erealloc(ignorance, ++nignorance*sizeof(*i));
+		i = &ignorance[nignorance - 1];
+		i->drop = drop;
 		i->len = strlen(p);
 		i->str = strdup(p);
-		if(i->str == 0){
-			free(i);
-			break;
-		}
-		i->next = ignorance;
-		ignorance = i;
+		if(i->str == nil)
+			sysfatal("strdup: %r");
 	}
 	Bterm(b);
 }
@@ -1547,9 +1571,9 @@
 	Ignorance *i;
 
 	readignore();
-	for(i = ignorance; i != nil; i = i->next)
+	for(i = ignorance; i != &ignorance[nignorance]; i++)
 		if(i->len <= n && cistrncmp(i->str, p, i->len) == 0)
-			return 1;
+			return i->drop;
 	return 0;
 }
 



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

* Re: [9front] upas/fs: header ignores
  2020-10-25  0:50 upas/fs: header ignores ori
@ 2020-10-25  1:07 ` Kurt H Maier
  2020-10-25  1:24   ` ori
  2020-10-25  2:21   ` Lyndon Nerenberg
  2020-10-25  2:43 ` Kurt H Maier
  2020-10-25 11:00 ` kvik
  2 siblings, 2 replies; 6+ messages in thread
From: Kurt H Maier @ 2020-10-25  1:07 UTC (permalink / raw)
  To: 9front

On Sat, Oct 24, 2020 at 05:50:51PM -0700, ori@eigenstate.org wrote:
> - Add /mail/lib/filterheaders, which has
>   a new syntax: lines default to keep, but
>   '!' can be used to drop a header:
> - Add defaults.

Not criticism, just curiosity:  why hardcode the defaults instead of
just shipping them in /mail/lib/filterheaders?

Also I haven't looked at this code, but is it possible to e.g. show
List-Unsubscribe (useful for commercial mail) but drop the other List-
headers?

khm


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

* Re: [9front] upas/fs: header ignores
  2020-10-25  1:07 ` [9front] " Kurt H Maier
@ 2020-10-25  1:24   ` ori
  2020-10-25  2:21   ` Lyndon Nerenberg
  1 sibling, 0 replies; 6+ messages in thread
From: ori @ 2020-10-25  1:24 UTC (permalink / raw)
  To: khm, 9front

> On Sat, Oct 24, 2020 at 05:50:51PM -0700, ori@eigenstate.org wrote:
>> - Add /mail/lib/filterheaders, which has
>>   a new syntax: lines default to keep, but
>>   '!' can be used to drop a header:
>> - Add defaults.
> 
> Not criticism, just curiosity:  why hardcode the defaults instead of
> just shipping them in /mail/lib/filterheaders?

Mainly, I want new users to have less files in there.
I find the current contents of /mail/lib overwhelming,
and having things Just Work with as few configs as
possible is a good thing, in my mind.

As a side effect, it keeps existing configs working.
Sysupdate won't touch /mail/lib to create the
filterheader file automatically.

> Also I haven't looked at this code, but is it possible to e.g. show
> List-Unsubscribe (useful for commercial mail) but drop the other List-
> headers?
> 
> khm

Yep:

	List-Unsubscribe:
	!List-

will match the list-unsubscribe header and accept it, then match
all other List- headers and reject them.



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

* Re: [9front] upas/fs: header ignores
  2020-10-25  1:07 ` [9front] " Kurt H Maier
  2020-10-25  1:24   ` ori
@ 2020-10-25  2:21   ` Lyndon Nerenberg
  1 sibling, 0 replies; 6+ messages in thread
From: Lyndon Nerenberg @ 2020-10-25  2:21 UTC (permalink / raw)
  To: 9front

> Not criticism, just curiosity:  why hardcode the defaults instead of
> just shipping them in /mail/lib/filterheaders?

+1

> Also I haven't looked at this code, but is it possible to e.g. show
> List-Unsubscribe (useful for commercial mail) but drop the other List-
> headers?

+1

I like how MH makes it easy to pick which headers you want to
display.


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

* Re: [9front] upas/fs: header ignores
  2020-10-25  0:50 upas/fs: header ignores ori
  2020-10-25  1:07 ` [9front] " Kurt H Maier
@ 2020-10-25  2:43 ` Kurt H Maier
  2020-10-25 11:00 ` kvik
  2 siblings, 0 replies; 6+ messages in thread
From: Kurt H Maier @ 2020-10-25  2:43 UTC (permalink / raw)
  To: 9front

On Sat, Oct 24, 2020 at 05:50:51PM -0700, ori@eigenstate.org wrote:
> +static Ignorance defaultignorance[] = {

Recommend adding Topicbox- to this list.

khm


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

* Re: [9front] upas/fs: header ignores
  2020-10-25  0:50 upas/fs: header ignores ori
  2020-10-25  1:07 ` [9front] " Kurt H Maier
  2020-10-25  2:43 ` Kurt H Maier
@ 2020-10-25 11:00 ` kvik
  2 siblings, 0 replies; 6+ messages in thread
From: kvik @ 2020-10-25 11:00 UTC (permalink / raw)
  To: 9front

I think this decision belongs with each user, rather than
being set system-wide.


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

end of thread, other threads:[~2020-10-25 11:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-25  0:50 upas/fs: header ignores ori
2020-10-25  1:07 ` [9front] " Kurt H Maier
2020-10-25  1:24   ` ori
2020-10-25  2:21   ` Lyndon Nerenberg
2020-10-25  2:43 ` Kurt H Maier
2020-10-25 11:00 ` kvik

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 NNTP newsgroup(s).