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 rd...@apache.org on 2009/04/01 17:50:20 UTC

svn commit: r760935 - in /james/imap/trunk: mailbox/src/main/java/org/apache/james/imap/mailbox/ mailbox/src/test/java/org/apache/james/imap/mailbox/ seda/src/test/java/org/apache/james/imap/functional/suite/ seda/src/test/resources/org/apache/james/im...

Author: rdonkin
Date: Wed Apr  1 15:50:20 2009
New Revision: 760935

URL: http://svn.apache.org/viewvc?rev=760935&view=rev
Log:
Fixed buggy expression parser IMAP-77 https://issues.apache.org/jira/browse/IMAP-77

Added:
    james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListPercentWildcard.test
Modified:
    james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java
    james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java
    james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/Listing.java

Modified: james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java?rev=760935&r1=760934&r2=760935&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java (original)
+++ james/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MailboxQuery.java Wed Apr  1 15:50:20 2009
@@ -177,11 +177,9 @@
                 for (int i = nameIndex; i < name.length(); i++) {
                     final char tasteNextName = name.charAt(i);
                     if (expressionNext == tasteNextName) {
-                        if (isLocalWildcardMatch(name, i, expressionIndex + 1,
-                                hierarchyDelimiter)) {
-                            matchRest = true;
-                            break;
-                        }
+                        matchRest = isLocalWildcardMatch(name, i + 1, expressionIndex + 1,
+                                hierarchyDelimiter);
+                        break;
                     } else if (tasteNextName == hierarchyDelimiter) {
                         matchRest = false;
                         break;
@@ -192,7 +190,8 @@
         } else {
             boolean containsDelimiter = false;
             for (int i = nameIndex; i < name.length(); i++) {
-                if (name.charAt(i) == hierarchyDelimiter) {
+                final char nextRemaining = name.charAt(i);
+                if (nextRemaining == hierarchyDelimiter) {
                     containsDelimiter = true;
                     break;
                 }

Modified: james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java?rev=760935&r1=760934&r2=760935&view=diff
==============================================================================
--- james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java (original)
+++ james/imap/trunk/mailbox/src/test/java/org/apache/james/imap/mailbox/MailboxExpressionTest.java Wed Apr  1 15:50:20 2009
@@ -299,4 +299,11 @@
         assertTrue(expression.isExpressionMatch(SECOND_PART + '.' + PART + '.'
                 + SECOND_PART + PART + SECOND_PART, '.'));
     }
+    
+    public void testTwoLocalWildcardsShouldMatchMailboxs() throws Exception {
+        MailboxQuery expression = create("%.%");
+        assertFalse(expression.isExpressionMatch(PART, '.'));
+        assertFalse(expression.isExpressionMatch(PART + '.' + SECOND_PART + '.' + SECOND_PART, '.'));
+        assertTrue(expression.isExpressionMatch(PART + '.' + SECOND_PART, '.'));
+    }
 }

Modified: james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/Listing.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/Listing.java?rev=760935&r1=760934&r2=760935&view=diff
==============================================================================
--- james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/Listing.java (original)
+++ james/imap/trunk/seda/src/test/java/org/apache/james/imap/functional/suite/Listing.java Wed Apr  1 15:50:20 2009
@@ -33,5 +33,24 @@
     public void testListPlusUS() throws Exception {
         scriptTest("ListPlus", Locale.US);
     }
+    
+    public void testListPercentWildcardUS() throws Exception {
+        scriptTest("ListPercentWildcard", Locale.US);
+    }
 
+    public void testListPlusKOREA() throws Exception {
+        scriptTest("ListPlus", Locale.KOREA);
+    }
+    
+    public void testListPercentWildcardKOREA() throws Exception {
+        scriptTest("ListPercentWildcard", Locale.KOREA);
+    }
+    
+    public void testListPlusITALY() throws Exception {
+        scriptTest("ListPlus", Locale.ITALY);
+    }
+    
+    public void testListPercentWildcardITALY() throws Exception {
+        scriptTest("ListPercentWildcard", Locale.ITALY);
+    }
 }

Added: james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListPercentWildcard.test
URL: http://svn.apache.org/viewvc/james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListPercentWildcard.test?rev=760935&view=auto
==============================================================================
--- james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListPercentWildcard.test (added)
+++ james/imap/trunk/seda/src/test/resources/org/apache/james/imap/scripts/ListPercentWildcard.test Wed Apr  1 15:50:20 2009
@@ -0,0 +1,75 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you under the Apache License, Version 2.0 (the            #
+# "License"); you may not use this file except in compliance   #
+# with the License.  You may obtain a copy of the License at   #
+#                                                              #
+#   http://www.apache.org/licenses/LICENSE-2.0                 #
+#                                                              #
+# Unless required by applicable law or agreed to in writing,   #
+# software distributed under the License is distributed on an  #
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       #
+# KIND, either express or implied.  See the License for the    #
+# specific language governing permissions and limitations      #
+# under the License.                                           #
+################################################################
+C: A01 CREATE one
+S: A01 OK CREATE completed.
+C: A02 CREATE two
+S: A02 OK CREATE completed.
+C: A03 CREATE three.sub
+S: A03 OK CREATE completed.
+C: A04 CREATE four.sub.sub
+S: A04 OK CREATE completed.
+C: A05 CREATE five
+S: A05 OK CREATE completed.
+
+C: A06 LIST "" %
+SUB {
+S: \* LIST \(\) \"\.\" \"one\"
+S: \* LIST \(\) \"\.\" \"two\"
+S: \* LIST \(\) \"\.\" \"three\"
+S: \* LIST \(\) \"\.\" \"four\"
+S: \* LIST \(\) \"\.\" \"five\"
+S: \* LIST \(\) \"\.\" \"INBOX\"
+}
+S: A06 OK LIST completed.
+
+C: A07 LIST "" "%"
+SUB {
+S: \* LIST \(\) \"\.\" \"one\"
+S: \* LIST \(\) \"\.\" \"two\"
+S: \* LIST \(\) \"\.\" \"three\"
+S: \* LIST \(\) \"\.\" \"four\"
+S: \* LIST \(\) \"\.\" \"five\"
+S: \* LIST \(\) \"\.\" \"INBOX\"
+}
+S: A07 OK LIST completed.
+
+C: A08 LIST "" "%.%"
+SUB {
+S: \* LIST \(\) \"\.\" \"three.sub\"
+S: \* LIST \(\) \"\.\" \"four.sub\"
+}
+S: A08 OK LIST completed.
+
+# Cleanup
+C: D1 DELETE "one"
+S: D1 OK DELETE completed.
+C: D2 DELETE "two"
+S: D2 OK DELETE completed.
+C: D3 DELETE "three"
+S: D3 OK DELETE completed.
+C: D4 DELETE "four"
+S: D4 OK DELETE completed.
+C: D5 DELETE "five"
+S: D5 OK DELETE completed.
+C: D6 DELETE "three.sub"
+S: D6 OK DELETE completed.
+C: D7 DELETE "four.sub"
+S: D7 OK DELETE completed.
+C: D8 DELETE "four.sub.sub"
+S: D8 OK DELETE completed.
\ No newline at end of file



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org