[Dovecot] Sieve regex match problem
I'm trying to make a regex to match common mailing list addresses and file messages to corresponding folders.
I'm using sieve-test to try and understand what is happening. The sieve script is:
require [ "fileinto", "regex", "variables" ]; if header :regex ["Sender"] ["(.*>[ \\t]*,?[ \\t]*)?([^-@]*)-([^-@]*)(-bounces)?@antlr.org"] {
fileinto "${0} :: 1:${1} 2:${2} 3:${3} 4:${4} 5:${5} 6:${6} 7:${7}"; }
The email contains:
Sender: antlr-interest-bounces@antlr.org
I'm trying to form a folder from the first two parts of the sender. In the real script, that will do a "fileto antlr.interest;"
Running sieve-test, I get:
- store message in folder: antlr-interest-bounces@antlr.org :: 1: 2:antlr 3: 4:interest 5: 6:-bounces 7:
I don't understand why parts 3 and 5 are empty. From the regex grouping, I expected
Part 2 "antlr" Part 3 "interest" Part 4 "-bounces"
The regex groups break done as: 1: (.*>[ \\t]*,?[ \\t]*)? - match leading name, comma or spaces 2: ([^-@]*) - match first part: 'antlr' in his case
3: ([^-@]*) - match second part: interest in this case 4: (-bounces)? - When cc'd, -bounces part isn't used- Hyphen between parts
The same regex tested with perl works as I expected.
Without the first group of the regex '(.*>[ \\t]*,?[ \\t]*)?', it works correctly. That group isn't getting matched anyway, so it shouldn't matter.
This is with 1.2alpha5.
What am I missing?
Thanks,
Andy
Andy Howell wrote:
Interesting use of the fileinto extension. ;) I'd better define a vnd.dovecot.debug extension to provide some sort of debug printing command. This would be an extension only provided by the sieve-test tool to provide such functionality more cleanly. This will print the values instantly in stead of waiting until the Sieve result is printed.
Fixed:
http://hg.rename-it.nl/dovecot-libsieve/rev/de6db6757418
As it turns out, I forgot to add the :regex match value handling to the test suite. I've now added a couple of simple tests based on your example.
Regards,
-- Stephan Bosch stephan@rename-it.nl
Andy Howell wrote:
Glad you like my creative use is 'fileinto. Thanks for the quick
fix. Are there plans to make another release of 1.2 any time soon?
Current code depends on unreleased changes in the Dovecot v1.2 tree. So, this will need to wait until Timo makes a new release.
Regards,
-- Stephan Bosch stephan@rename-it.nl
participants (2)
-
Andy Howell
-
Stephan Bosch