You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2022/03/22 02:03:41 UTC

[james-project] 12/25: JAMES-3722 SELECT + QRESYNC did not comply with formal syntax

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 824e8f6ec3fbfd30651738f2ade1c693f36f0e85
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Mar 8 09:21:24 2022 +0700

    JAMES-3722 SELECT + QRESYNC did not comply with formal syntax
    
    sequence match data can theorically be specified without known uids.
    
    CF:
    select-param        =  \"QRESYNC\" SP \"(\" uidvalidity SP" +
                            mod-sequence-value [SP known-uids]
                            [SP seq-match-data]
---
 .../decode/parser/AbstractSelectionCommandParser.java  | 18 ++++++++++++------
 .../apache/james/imapserver/netty/IMAPServerTest.java  |  5 -----
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java
index 8959299..d06f2f1 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/decode/parser/AbstractSelectionCommandParser.java
@@ -35,9 +35,12 @@ import org.apache.james.imap.message.request.AbstractMailboxSelectionRequest;
 import org.apache.james.imap.message.request.AbstractMailboxSelectionRequest.ClientSpecifiedUidValidity;
 import org.apache.james.mailbox.MessageUid;
 
+import com.google.common.base.CharMatcher;
+
 public abstract class AbstractSelectionCommandParser extends AbstractImapCommandParser {
     private static final String CONDSTORE = ImapConstants.SUPPORTS_CONDSTORE.asString();
     private static final String QRESYNC = ImapConstants.SUPPORTS_QRESYNC.asString();
+    private static final CharMatcher NUMERIC = CharMatcher.inRange('0', '9');
 
     public AbstractSelectionCommandParser(ImapCommand command, StatusResponseFactory statusResponseFactory) {
         super(command, statusResponseFactory);
@@ -89,15 +92,18 @@ public abstract class AbstractSelectionCommandParser extends AbstractImapCommand
                        
                     // Consume the SP
                     request.consumeChar(' ');
-                    uidSet = request.parseUidRange();
-                    
-                    // Check for *
-                    checkUidRanges(uidSet, false);
+                    if (NUMERIC.matches(request.nextChar())) {
+                        uidSet = request.parseUidRange();
+                        // Check for *
+                        checkUidRanges(uidSet, false);
+                    }
                     
                     nc = request.nextChar();
-                    if (nc == ' ')  {
+                    if (nc == ' ') {
                         request.consumeChar(' ');
-                        
+                    }
+                    nc = request.nextChar();
+                    if (nc == '(') {
                         // This is enclosed in () so remove (
                         request.consumeChar('(');
                         knownSequenceSet = request.parseIdRange();
diff --git a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
index e5d78ef..54ad3d6 100644
--- a/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
+++ b/server/protocols/protocols-imap4/src/test/java/org/apache/james/imapserver/netty/IMAPServerTest.java
@@ -1517,11 +1517,6 @@ class IMAPServerTest {
                 .hasSize(1);
         }
 
-        @Disabled("JAMES-3722 SELECT + QRESYNC did not comply with formal syntax: sequence match data can theorically" +
-            "be specified without known uids. CF:" +
-            "   select-param        =  \"QRESYNC\" SP \"(\" uidvalidity SP" +
-            "           mod-sequence-value [SP known-uids]" +
-            "           [SP seq-match-data]")
         @Test
         void selectShouldReturnDeletedMessagesWhenSequenceMatchDataAndNoKnownUid() throws Exception {
             inbox.delete(ImmutableList.of(MessageUid.MIN_VALUE), mailboxSession);

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