Re: It's not possible to create folder which name starts with hash-sign (#)

Wojtek <[email protected]>
Newsgroups gmane.comp.jakarta.james.user
Message-ID <[email protected]>
I've been debugging it a bit and I _think_ the problem is with 
`org.apache.james.imap.main.PathConverter#isAbsolute` 
(https://github.com/apache/james-project/blob/master/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java#L60) 
method.

My understanding is that it should check if this is absolute path (i.e. 
`#<namespace>:username:folder`) but because it only checks first character then it also returns 
"true" for simple folder name like "#test".

Maybe using `session.supportMultipleNamespaces() && mailboxName.charAt(0) == 
MailboxConstants.NAMESPACE_PREFIX_CHAR;` would work?

Then I ran into another issue with `org.apache.james.mailbox.model.MailboxPath#assertAcceptable` 
(https://github.com/apache/james-project/blob/master/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxPath.java#L222) 
which also does the check.

It was introduced in https://issues.apache.org/jira/browse/MAILBOX-392 / 
https://github.com/linagora/james-project/pull/4168 but the MailboxPath class already has namespace 
/ user / name as separate members so I'm not sure that `name.startsWith("#");` check makes sense (it 
can't be namespace indication as we already have namespace apart)

After modifying `isAbsolute()` and `nameContainsForbiddenCharacters()` it seems to work fine(-ish*).

(* - the LIST after creation gives absolute path: `A7 LIST "" #hashtest11` … * `LIST 
(\HasNoChildren) "." "#private.admin@atlantiscity.#hashtest11"`)

I tried to run tests from Idea but again ran into issues with Scala, so I'll have to figure out 
better way to run them:
```
EventStore is already defined as trait EventStore
trait EventStore {
```

Wojtek

On 22/06/2023 11:01, Wojtek wrote:
> Hi,
> 
> 
> Wojtek
> 
> On 22/06/2023 01:32, Benoit TELLIER wrote:
>> Hello Wojtek,
>>
>> That is because James employs a folder hierarchy where '#' is used to denote a namespace.
> 
> I assumed as much.
> 
>> #private:wojtek:INBOX denotes your inbox on which I would have a shared access.
>> #shared:marketting:INBOX denotes a shared mailbox for the marketting team.
>>
>> I bet you could do: #private:wojtek:#hashtest ?
> 
> Unfortunately not:
> 
> ```
> A4 CREATE #private:admin@atlantiscity:#hashtest
> A4 NO CREATE You can not access a mailbox that does not belong to you
> ```
> 
> [More at the end]
> 
> ( `store.getFolder("#private:" + email + ":#hashtest").create(HOLDS_MESSAGES)` )
> 
> What's weird is that the original exception that made me investigate it didn't have hashtag in the 
> foldername itself:
> ```
> 21:33:47.588 [ERROR] o.a.j.i.p.StatusProcessor - Status failed for mailbox 
> #private:[email protected]:Apple Mail To Do
> org.apache.james.mailbox.exception.MailboxNotFoundException: #private:[email protected]:Apple 
> Mail To Do can not be found
>          at 
> org.apache.james.mailbox.store.StoreMailboxManager.lambda$getMailboxReactive$1(StoreMailboxManager.java:282)
> ```
> 
> 
>> That being said, james have no support for accessing shared mailboxes in IMAP just quite yet. The 
>> usefulness of that addressing scheme is thus limited.
>>
>> IMO we could:
>>   - Drop the #namespace:user:mailbox addressing sheme in IMAP as it is not currently in use...
>>   - Or (lighter) if we can't parse a mailbox path (no : after #) then keep the name as is, IE 
>> support #hashtest
>>   - Review and adopt another addressing sheme that matches those of eg cyrus.
> 
> I'm not sure how other implementations do it (only checked it from the end-user point of view).
> 
> As you mentioned, the namespaces doesn't seem to be directly visible in IMAP, nor it's possible to 
> act on them - they are in the repository ("namespace" column) but that's just about it - LIST only 
> shows effective folder name (i.e. "INBOX" and not "#private:wojtek:INBOX").
> 
> Trying to create mailbox that starts with `#`, be that namespace (#private:admin@atlantiscity:test) 
> or plain folder (#test) name just doesn't work.
> 
> RFC mentiones namespaces (https://datatracker.ietf.org/doc/html/rfc3501#page-19) but the example is 
> about usenet. I'm not sure how they are used in James (especially outside IMAP that you mentioned).
> 
> I couldn't find it in the documentation, but through searching I found:
> https://github.com/apache/james-project/pull/680
> https://issues.apache.org/jira/browse/JAMES-3659
> https://www.mail-archive.com/[email protected]/msg71116.html
> and finally
> https://github.com/apache/james-project/blob/master/server/protocols/jmap-rfc-8621/doc/specs/spec/mail/rights.mdown
> 
> Which seems JMAP focused.
> 
> The concept of shared mailbox/being able to send messages on behalf of someone seems interesting 
> though (at least in our case) usual modus operandi (for example for having support email) is:
> - have dedicated mailbox for support user
> - have ticketing system that ties to that mailbox -- users simply interact via tickets
> 
> 
> 
> 
> 
> Regarding possible solutions - maybe, if not referenced directly in IMAP (i.e. if someone doesn't 
> ask about namespaced mailbox, i.e. in format `#<namespace>:username:folder`) then treat it as 
> "simple folder" and allow hash sign. Alternatively if someone uses full format then try to access 
> shared mailbox? I guess it would be akin your second suggestion or some sort of mix between first 
> and second?
> Though, I'm not sure if there is any IMAP client that could use it so maybe first option - drop it 
> altogether from IMAP - would be better?
> 
> 
> 
> 
> 
> Btw. "#" is reserved in James, but only as a prefix (it works in the middle of the folder name):
> 
> A4 CREATE #private:admin@atlantiscity:test
> A4 NO CREATE You can not access a mailbox that does not belong to you
> 
> A5 CREATE #shared:admin@atlantiscity:test
> A5 NO CREATE You can not access a mailbox that does not belong to you
> 
> A6 CREATE #private:admin@atlantiscity:#hashtest
> A6 NO CREATE You can not access a mailbox that does not belong to you
> 
> A7 CREATE #shared:admin@atlantiscity:#hashtest
> A7 NO CREATE You can not access a mailbox that does not belong to you
> 
> A8 CREATE #private:admin@atlantiscity:bla#hashtest
> A8 NO CREATE You can not access a mailbox that does not belong to you
> 
> A9 CREATE #shared:admin@atlantiscity:bla#hashtest
> A9 NO CREATE You can not access a mailbox that does not belong to you
> 
> A10 CREATE test2
> A10 OK [MAILBOXID (27110)] CREATE completed.
> 
> A12 CREATE #hashtest2
> A12 NO CREATE You can not access a mailbox that does not belong to you
> 
> A13 CREATE bla#hashtest2
> A13 OK [MAILBOXID (27111)] CREATE completed.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.