See JSIEVE-19 comments for updates on this.
I committed what I did so you see for real one of the solution (as I did it). If it is not ok and you prefer another solution, feel free to complain and I'll revert the change.

Stefano

Stefano Bagnara ha scritto:
I investigated a bit on this issue.
Sieve specification says:
----
The ":matches" version specifies a wildcard match using the characters "*" and "?". "*" matches zero or more characters, and "?" matches a single character. "?" and "*" may be escaped as "\\?" and "\\*" in strings to match against themselves.
----
This means only * and ? are special chars.
Instead jSieve uses a Glob expression compiler for the matches operator:
http://james.apache.org/jsieve/xref/org/apache/jsieve/comparators/ComparatorUtils.html#104
http://jakarta.apache.org/oro/api/org/apache/oro/text/GlobCompiler.html

The problem is that a Glob expression supports much more than * and ?. So what is the solution to this? One solution is to write a custom oro.text.regex.PatternCompiler and use it. Another solution is to escape some of the chars in order to make the GlobCompiler work with * and ? only. Otherwise we could rewrite the input string to a Perl5regexp or a java regex before compiling. IMHO it is interesting to note that jSieve depends on ORO just for this class, so maybe the best thing would be to write our own matcher or to use builtin java regex.
WDYT?

As a side note: why the ComparatorUtils uses the weird get/getBasic/update/set/compute pattern for the GlobCompiler and for the Perl5Matcher given that they are private and used only by static methods (so I see not really a single advantage over a simple lazy instantiation, because it could not anyway be overridden) ???

Stefano

Stefano Bagnara (JIRA) ha scritto:
Open square bracket as first char in matching pattern does not work
-------------------------------------------------------------------

                 Key: JSIEVE-19
                 URL: https://issues.apache.org/jira/browse/JSIEVE-19
             Project: jSieve
          Issue Type: Bug
    Affects Versions: 0.2
            Reporter: Stefano Bagnara
             Fix For: 0.2


this rule
if header :matches \"X-Caffeine\" \"[test]*\" {throwTestException;}
does not match for X-Caffeine: [test] something

Removing the open square or moving it as the second char instead works.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to