Re: [Dovecot] Sieve regex match problem

2009-01-22 Thread Stephan Bosch

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
step...@rename-it.nl


Re: [Dovecot] Sieve regex match problem

2009-01-21 Thread Andy Howell

Stephan Bosch wrote:

Andy Howell wrote:


Running sieve-test, I get:

 * store message in folder: antlr-interest-boun...@antlr.org :: 1: 
2:antlr 3: 4:interest 5: 6:-bounces 7:
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.


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?
Nothing, this is a bug. If a non-matched match value is encountered, the 
indexes of the match values after that are mangled.


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,

	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?


Regards,

Andy




Re: [Dovecot] Sieve regex match problem

2009-01-21 Thread Stephan Bosch

Andy Howell wrote:


Running sieve-test, I get:

 * store message in folder: antlr-interest-boun...@antlr.org :: 1: 
2:antlr 3: 4:interest 5: 6:-bounces 7:
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.


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?
Nothing, this is a bug. If a non-matched match value is encountered, the 
indexes of the match values after that are mangled.


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
step...@rename-it.nl


[Dovecot] Sieve regex match problem

2009-01-21 Thread Andy Howell


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-boun...@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-boun...@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
-- Hyphen between parts
3: ([...@]*)  - match second part: interest in this case
4: (-bounces)?   - When cc'd, -bounces part isn't used

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