Gnus development mailing list
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: nnmail-split-fancy usability problem
Date: Sun, 29 Jun 2003 13:27:53 +0200	[thread overview]
Message-ID: <87u1a9jf7q.fsf@deneb.enyo.de> (raw)

Let's say we have list postings with the following header:

List-Id: An example list <list.example.com>

Say we want to use a generic rule which processes all lists at
example.com.  The following doesn't work because "<" is not a word
constituent:

("List-Id" "<\\([a-z0-9-]+\\)\\.example\\.com>" "lists.example.\\1")

This doesn't work either because ".*" is greedy.

("List-Id" ".*\\([a-z0-9-]+\\)\\.example\\.com" "lists.example.\\1")

After rewriting, this results in an illegal regular expression (".*"
at the beginning is dropped unconditionally).

("List-Id" ".*?\\([a-z0-9-]+\\)\\.example\\.com" "lists.example.\\1")

Fortunately, the rule below works because the initial ".*" suppresses
the word constituent check:

("List-Id" ".*<\\([a-z0-9-]+\\)\\.example\\.com>.*" "lists.example.\\1")

However, we are a bit lucky.  If there weren't the "<" character as a
marker, I think we would have a hard time working around the greedy
".*" in the header field matcher.

The following patch changes the implicit ".*" to ".*?".  Okay to
apply?

(However, IMHO, the whole behavior of nnmail-split-fancy is highly
non-intuitive.)

2003-06-29  Florian Weimer  <fw@deneb.enyo.de>

	* nnmail.el (nnmail-split-it): Make header field match
          non-greedy.

--- nnmail.el.~6.77.~	2003-06-29 12:50:50.000000000 +0200
+++ nnmail.el	2003-06-29 13:19:13.000000000 +0200
@@ -1306,7 +1306,7 @@
 	    (push split nnmail-split-trace))
 	  (let ((split-rest (cddr split))
 		(end (match-end 0))
-		;; The searched regexp is \(\(FIELD\).*\)\(VALUE\).
+		;; The searched regexp is \(\(FIELD\).*?\)\(VALUE\).
 		;; So, start-of-value is the point just before the
 		;; beginning of the value, whereas after-header-name
 		;; is the point just after the field name.
@@ -1366,7 +1366,7 @@
 			     (if (symbolp field)
 				 (cdr (assq field nnmail-split-abbrev-alist))
 			       field)
-			     "\\):.*\\)"
+			     "\\):.*?\\)"
 			     (or partial-front "\\<")
 			     "\\("
 			     value



             reply	other threads:[~2003-06-29 11:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-29 11:27 Florian Weimer [this message]
2003-06-29 13:33 ` Michael Cook
2003-06-29 13:37   ` Florian Weimer
2003-06-30 23:24 ` Johan Bockgård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87u1a9jf7q.fsf@deneb.enyo.de \
    --to=fw@deneb.enyo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).