You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ba...@apache.org on 2008/05/12 11:24:24 UTC
svn commit: r655450 - in /james/jsieve/trunk/src:
main/java/org/apache/jsieve/comparators/ComparatorUtils.java
test/java/org/apache/jsieve/junit/HeaderTest.java
Author: bago
Date: Mon May 12 02:24:23 2008
New Revision: 655450
URL: http://svn.apache.org/viewvc?rev=655450&view=rev
Log:
ComparatorUtils.match should be case sensitive.
Added a test for special chars escaping (JSIEVE-19)
Modified:
james/jsieve/trunk/src/main/java/org/apache/jsieve/comparators/ComparatorUtils.java
james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java
Modified: james/jsieve/trunk/src/main/java/org/apache/jsieve/comparators/ComparatorUtils.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/main/java/org/apache/jsieve/comparators/ComparatorUtils.java?rev=655450&r1=655449&r2=655450&view=diff
==============================================================================
--- james/jsieve/trunk/src/main/java/org/apache/jsieve/comparators/ComparatorUtils.java (original)
+++ james/jsieve/trunk/src/main/java/org/apache/jsieve/comparators/ComparatorUtils.java Mon May 12 02:24:23 2008
@@ -79,7 +79,7 @@
// TODO Is there a way to re-use the compiled pattern?
try {
String regex = sieveToJavaRegex(glob);
- return Pattern.compile(regex, Pattern.CASE_INSENSITIVE).matcher(
+ return Pattern.compile(regex).matcher(
string).matches();
} catch (PatternSyntaxException e) {
throw new SievePatternException(e.getMessage());
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java?rev=655450&r1=655449&r2=655450&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java Mon May 12 02:24:23 2008
@@ -353,4 +353,42 @@
assertTrue(isTestPassed);
}
+ /**
+ * Test for special char escaping: \\? is a ? and \\* is an *
+ */
+ public void testSpecialCharsEscapingInMatch() {
+ boolean isTestPassed = false;
+ String script = "if header :matches \"X-Caffeine\" \"my,\\\\,?,\\?,\\\\?,*,\\*,\\\\*,pattern\" {throwTestException;}";
+ try {
+ SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
+ mail.getMessage().addHeader("X-Caffeine", "my,\\,x,x,?,foo,bar,*,pattern");
+ JUnitUtils.interpret(mail, script);
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
+ }
+ assertTrue(isTestPassed);
+ }
+
+ /**
+ * Test for special char escaping: \\? is a ? and \\* is an *
+ */
+ public void testSpecialCharsEscapingInMatchFalse() {
+ boolean isTestPassed = false;
+ String script = "if header :matches \"X-Caffeine\" \"my,?,\\?,\\\\?,*,\\*,\\\\*,pattern\" {throwTestException;}";
+ try {
+ SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
+ mail.getMessage().addHeader("X-Caffeine", "my,x,x,q,foo,bar,*,pattern");
+ JUnitUtils.interpret(mail, script);
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
+ }
+ assertTrue(isTestPassed);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org