You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/10/30 03:42:13 UTC
(james-project) 37/37: JAMES-2128 Ensure creating #user is forbidden
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit ee0c957dc583b854b630de57eafc9b90047b645d
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Tue Oct 22 14:27:48 2024 +0200
JAMES-2128 Ensure creating #user is forbidden
---
.../src/main/java/org/apache/james/mailbox/model/MailboxPath.java | 6 ++++--
.../src/main/resources/org/apache/james/imap/scripts/Create.test | 3 +++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
index d43641de5d..24abfdad66 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java
@@ -154,7 +154,9 @@ public class MailboxPath {
}
public boolean belongsTo(MailboxSession mailboxSession) {
- return user.equals(mailboxSession.getUser());
+ return Optional.ofNullable(user)
+ .map(mailboxSession.getUser()::equals)
+ .orElse(false);
}
public MailboxPath child(String childName, char delimiter) {
@@ -255,7 +257,7 @@ public class MailboxPath {
}
public String asString() {
- return namespace + ":" + user.asString() + ":" + name;
+ return namespace + ":" + Optional.ofNullable(user).map(Username::asString).orElse("") + ":" + name;
}
public String asEscapedString() {
diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Create.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Create.test
index 4f47c8b1fb..438e4d890f 100644
--- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Create.test
+++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/Create.test
@@ -73,6 +73,9 @@ S: \* LIST \(\\HasChildren\) "." "one"
S: \* LIST \(\\HasNoChildren\) "." "one.two"
S: 21 OK LIST completed.
+C: 22 CREATE #user
+S: 22 NO CREATE processing failed.
+
# Cleanup
C: a1 DELETE test1.subfolder1
S: a1 OK DELETE completed.
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org