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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to