user/dev discussion of public-inbox itself
 help / color / Atom feed
* [RFC 0/2] watch behavior changes aNd ProPoSaL
@ 2020-04-23  8:34 Eric Wong
  2020-04-23  8:34 ` [PATCH 1/2] watchmaildir: scan all matching headers Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-23  8:34 UTC (permalink / raw)
  To: meta

Now, I don't think the following two patches will cause any
problems for existing users...

Down the line, for matching non-List-ID headers insensitively,
I'm thinking "mutt style" case-sensitivity is probably a good
default.  That is:

	Match case-sensitively iff capital letters exist in
	the substring.  Otherwise, match case-insensitively.

But, mutt allows POSIX regexps...  I'm not sure if regexps are
necessary for this, and I also don't want this to be tied to
Perl/PCRE in case we or someone else wants to use another
language/runtime.  We can't use POSIX regexps from Perl w/o
XS from CPAN or Inline::C, so more crap to force on the user.

Otherwise, I'm not sure how a user should (or would care to)
specify case-insensitivity vs case-sensitivity...

Valid email headers names won't have spaces (or many other
chars), so we can do somthing like attempt to parse out " -i"
(like "grep -i"):

	watchheader = To -i:John Smith

Or, add a new option:

	watchHeaderInsensitively = To:John Smith

Ugh...

Eric Wong (2):
  watchmaildir: scan all matching headers
  watchmaildir: match List-ID case-insensitively

 lib/PublicInbox/WatchMaildir.pm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

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

* [PATCH 1/2] watchmaildir: scan all matching headers
  2020-04-23  8:34 [RFC 0/2] watch behavior changes aNd ProPoSaL Eric Wong
@ 2020-04-23  8:34 ` Eric Wong
  2020-04-23  8:34 ` [PATCH 2/2] watchmaildir: match List-ID case-insensitively Eric Wong
  2020-04-24  3:12 ` [RFC 0/2] watch behavior changes aNd ProPoSaL Kyle Meyer
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-23  8:34 UTC (permalink / raw)
  To: meta

Some headers may appear more than once in a message, so it's
probably best to ensure we attempt matches on all of them.

This ought to allow matching on Received: or similar because a
list lacks List-IDs :P
---
 lib/PublicInbox/WatchMaildir.pm | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 7b9e8915..02e4b32f 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -175,10 +175,8 @@ sub _try_path {
 			my $ok;
 			my $hdr = $mime->header_obj;
 			for my $wh (@$watch_hdrs) {
-				my $v = $hdr->header_raw($wh->[0]);
-				next unless defined($v) && $v =~ $wh->[1];
-				$ok = 1;
-				last;
+				my @v = $hdr->header_raw($wh->[0]);
+				$ok = grep(/$wh->[1]/, @v) and last;
 			}
 			next unless $ok;
 		}

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

* [PATCH 2/2] watchmaildir: match List-ID case-insensitively
  2020-04-23  8:34 [RFC 0/2] watch behavior changes aNd ProPoSaL Eric Wong
  2020-04-23  8:34 ` [PATCH 1/2] watchmaildir: scan all matching headers Eric Wong
@ 2020-04-23  8:34 ` Eric Wong
  2020-04-24  3:12 ` [RFC 0/2] watch behavior changes aNd ProPoSaL Kyle Meyer
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2020-04-23  8:34 UTC (permalink / raw)
  To: meta

RFC 2919 section 6 states the following:

  There is only one operation defined for list identifiers,
  that of case insensitive equality.

So no arguing with that.  Now, the other headers are
open to interpretation, so put a note about them.
---
 lib/PublicInbox/WatchMaildir.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/WatchMaildir.pm b/lib/PublicInbox/WatchMaildir.pm
index 02e4b32f..71bd84fc 100644
--- a/lib/PublicInbox/WatchMaildir.pm
+++ b/lib/PublicInbox/WatchMaildir.pm
@@ -62,12 +62,17 @@ sub new {
 			if (my $whs = $ibx->{watchheader}) {
 				for (@$whs) {
 					my ($k, $v) = split(/:/, $_, 2);
+					# XXX should this be case-insensitive?
+					# Or, mutt-style, case-sensitive iff
+					# a capital letter exists?
 					push @$watch_hdrs, [ $k, qr/\Q$v\E/ ];
 				}
 			}
 			if (my $list_ids = $ibx->{listid}) {
 				for (@$list_ids) {
-					my $re = qr/<[ \t]*\Q$_\E[ \t]*>/;
+					# RFC2919 section 6 stipulates
+					# "case insensitive equality"
+					my $re = qr/<[ \t]*\Q$_\E[ \t]*>/i;
 					push @$watch_hdrs, ['List-Id', $re ];
 				}
 			}

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

* Re: [RFC 0/2] watch behavior changes aNd ProPoSaL
  2020-04-23  8:34 [RFC 0/2] watch behavior changes aNd ProPoSaL Eric Wong
  2020-04-23  8:34 ` [PATCH 1/2] watchmaildir: scan all matching headers Eric Wong
  2020-04-23  8:34 ` [PATCH 2/2] watchmaildir: match List-ID case-insensitively Eric Wong
@ 2020-04-24  3:12 ` Kyle Meyer
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Meyer @ 2020-04-24  3:12 UTC (permalink / raw)
  To: Eric Wong; +Cc: meta

Eric Wong <e@yhbt.net> writes:

> Now, I don't think the following two patches will cause any
> problems for existing users...
>
> Down the line, for matching non-List-ID headers insensitively,
> I'm thinking "mutt style" case-sensitivity is probably a good
> default.  That is:
>
> 	Match case-sensitively iff capital letters exist in
> 	the substring.  Otherwise, match case-insensitively.

Yeah, I find this behavior to be pretty intuitive/nice, though I guess
the only context where I've (knowingly) used it is Emacs search, so that
might discount my 2 cents :)

However, if it's either this or an option like...

> Otherwise, I'm not sure how a user should (or would care to)
> specify case-insensitivity vs case-sensitivity...
>
> Valid email headers names won't have spaces (or many other
> chars), so we can do somthing like attempt to parse out " -i"
> (like "grep -i"):
>
> 	watchheader = To -i:John Smith

... this, I guess this one has the advantage of being able to
case-sensitively match all lowercase?  I'm not sure how much practical
value there is to that, though.

I think the -i proposal above is nicer than this next one, but I suppose
it'd have the same advantage.

> Or, add a new option:
>
> 	watchHeaderInsensitively = To:John Smith
>
> Ugh...

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

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23  8:34 [RFC 0/2] watch behavior changes aNd ProPoSaL Eric Wong
2020-04-23  8:34 ` [PATCH 1/2] watchmaildir: scan all matching headers Eric Wong
2020-04-23  8:34 ` [PATCH 2/2] watchmaildir: match List-ID case-insensitively Eric Wong
2020-04-24  3:12 ` [RFC 0/2] watch behavior changes aNd ProPoSaL Kyle Meyer

user/dev discussion of public-inbox itself

Archives are clonable:
	git clone --mirror http://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

Example config snippet for mirrors

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.io/gmane.mail.public-inbox.general

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

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