Author: norman
Date: Wed May 11 14:17:34 2011
New Revision: 1101890

URL: http://svn.apache.org/viewvc?rev=1101890&view=rev
Log:
Handle better parsing of search keys which are enclosed by "( )". See IMAP-283

Modified:
    
james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java

Modified: 
james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
URL: 
http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java?rev=1101890&r1=1101889&r2=1101890&view=diff
==============================================================================
--- 
james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
 (original)
+++ 
james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/ImapRequestLineReader.java
 Wed May 11 14:17:34 2011
@@ -311,12 +311,18 @@ public abstract class ImapRequestLineRea
      * and an exception is thrown if invalid characters are encountered.
      */
     public String consumeWord(CharacterValidator validator) throws 
DecodingException {
+        return consumeWord(validator, false);
+    }
+
+    private String consumeWord(CharacterValidator validator, boolean 
stripParen) throws DecodingException {
         StringBuffer atom = new StringBuffer();
 
         char next = nextWordChar();
-        while (!isWhitespace(next)) {
+        while (!isWhitespace(next) && (stripParen == false || next != ')')) {
             if (validator.isValid(next)) {
-                atom.append(next);
+                if (stripParen == false || next != '(') {
+                    atom.append(next);
+                }
                 consume();
             } else {
                 throw new 
DecodingException(HumanReadableText.ILLEGAL_ARGUMENTS, "Invalid character: '" + 
next + "'");
@@ -325,7 +331,6 @@ public abstract class ImapRequestLineRea
         }
         return atom.toString();
     }
-
     private static boolean isWhitespace(char next) {
         return (next == ' ' || next == '\n' || next == '\r' || next == '\t');
     }
@@ -574,7 +579,9 @@ public abstract class ImapRequestLineRea
      */
     public IdRange[] parseIdRange() throws DecodingException {
         CharacterValidator validator = new MessageSetCharValidator();
-        String nextWord = consumeWord(validator);
+        // Don't fail to parse id ranges which are enclosed by "(..)"
+        // See IMAP-283
+        String nextWord = consumeWord(validator, true);
 
         int commaPos = nextWord.indexOf(',');
         if (commaPos == -1) {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to