Skip to content

Commit

Permalink
JAMES-2128 Ensure creating #user is forbidden
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Oct 22, 2024
1 parent f549a1f commit 0455d60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ public String getName() {
}

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) {
Expand Down Expand Up @@ -255,7 +257,7 @@ boolean hasEmptyNameInHierarchy(char pathDelimiter) {
}

public String asString() {
return namespace + ":" + user.asString() + ":" + name;
return namespace + ":" + Optional.ofNullable(user).map(Username::asString).orElse("") + ":" + name;
}

public String asEscapedString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0455d60

Please sign in to comment.