JAMES-2110 Allow hyphen minus as part of keyword

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4e44ec15
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4e44ec15
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4e44ec15

Branch: refs/heads/master
Commit: 4e44ec1504a69e6cf6a2bac67827faba4d678e6a
Parents: 0512dab
Author: benwa <btell...@linagora.com>
Authored: Fri Apr 6 14:25:00 2018 +0700
Committer: benwa <btell...@linagora.com>
Committed: Mon Apr 9 14:31:04 2018 +0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/james/jmap/model/Keyword.java  | 3 ++-
 .../test/java/org/apache/james/jmap/model/KeywordTest.java  | 9 +++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/4e44ec15/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keyword.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keyword.java 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keyword.java
index 1ea0ed4..761d41d 100644
--- 
a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keyword.java
+++ 
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/Keyword.java
@@ -38,7 +38,8 @@ public class Keyword {
     private static final CharMatcher FLAG_NAME_PATTERN =
             CharMatcher.JAVA_LETTER_OR_DIGIT
                 .or(CharMatcher.is('$'))
-                .or(CharMatcher.is('_'));
+                .or(CharMatcher.is('_')
+                .or(CharMatcher.is('-')));
 
     public static final Keyword DRAFT = new Keyword("$Draft");
     public static final Keyword SEEN = new Keyword("$Seen");

http://git-wip-us.apache.org/repos/asf/james-project/blob/4e44ec15/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordTest.java
----------------------------------------------------------------------
diff --git 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordTest.java
 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordTest.java
index c175e6d..a729205 100644
--- 
a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordTest.java
+++ 
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/KeywordTest.java
@@ -20,6 +20,7 @@
 package org.apache.james.jmap.model;
 
 import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
 
 import java.util.Optional;
 
@@ -195,4 +196,12 @@ public class KeywordTest {
         assertThat(keyword.asFlags())
             .isEqualTo(new Flags(userFlag));
     }
+
+    @Test
+    public void hyphenMinusShouldBeAllowedInKeyword() {
+        String userFlag = "aa-bb";
+
+        assertThatCode(() -> new Keyword(userFlag))
+            .doesNotThrowAnyException();
+    }
 }
\ No newline at end of file


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

Reply via email to