Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

\* is not a valid IMAP flag #633

Closed
nevans opened this issue Nov 17, 2023 · 4 comments
Closed

\* is not a valid IMAP flag #633

nevans opened this issue Nov 17, 2023 · 4 comments
Labels
backport_1_6_x Backport to old bugfixing branch 1.6.x backport_2_0_x Backport to branch 2.0.x breaking change bug
Milestone

Comments

@nevans
Copy link

nevans commented Nov 17, 2023

The default FLAGS response for the SELECT command sends \*, which is valid for PERMANENTFLAGS but not for FLAGS. See RFC3501 or RFC9051:

The PERMANENTFLAGS list can also include the special flag \*, which indicates that it is possible to create new keywords by attempting to store those flags in the mailbox.

(emphasis is mine)

The relevant formal syntax (note that * is not a valid ATOM-CHAR):

atom            = 1*ATOM-CHAR

ATOM-CHAR       = <any CHAR except atom-specials>

atom-specials   = "(" / ")" / "{" / SP / CTL / list-wildcards /
                  quoted-specials / resp-specials

list-wildcards  = "%" / "*"

flag            = "\Answered" / "\Flagged" / "\Deleted" /
                  "\Seen" / "\Draft" / flag-keyword / flag-extension
                    ; Does not include "\Recent"

flag-extension  = "\" atom
                    ; Future expansion.  Client implementations
                    ; MUST accept flag-extension flags.  Server
                    ; implementations MUST NOT generate
                    ; flag-extension flags except as defined by
                    ; future standard or standards-track
                    ; revisions of this specification.

flag-keyword    = atom

flag-list       = "(" [flag *(SP flag)] ")"

flag-perm       = flag / "\*"

mailbox-data    =/ "FLAGS" SP flag-list

resp-text-code  =/ "PERMANENTFLAGS" SP "("
                  [flag-perm *(SP flag-perm)] ")"

And the relevant code is here (I think):

Perhaps a mailbox.getFlags() method could be added that simply filters out \* from mailbox.getPermanentFlags()?

@nevans
Copy link
Author

nevans commented Nov 17, 2023

By the way, do you know if any "real" servers respond with \* as a (non-permanent) flag? I ask because I haven't seen any myself and I'd prefer to keep my client protocol parsing code strict on this. But if it does occur in the wild, I'll pragmatically parse more loosely.

@nevans nevans closed this as completed Nov 17, 2023
@nevans nevans reopened this Nov 17, 2023
@nevans
Copy link
Author

nevans commented Nov 17, 2023

oops... I accidentally tapped the close button there!

nevans added a commit to ruby/net-imap that referenced this issue Nov 17, 2023
@marcelmay
Copy link
Member

Thx alot for the detailed bug report, @nevans .

Regarding you question: I can not say anything about 'real' mail servers, unfortunately.

@marcelmay marcelmay added the bug label Nov 19, 2023
@marcelmay
Copy link
Member

marcelmay commented Nov 19, 2023

Interesting: The SELECT FLAGS result (availableFlags) is more or less ignored in JakartaMail reference implementation ...

@marcelmay marcelmay added backport_1_6_x Backport to old bugfixing branch 1.6.x backport_2_0_x Backport to branch 2.0.x labels Nov 19, 2023
@marcelmay marcelmay added this to the 2.1.0-alpha-4 milestone Nov 19, 2023
nevans added a commit to ruby/net-imap that referenced this issue Nov 20, 2023
nevans added a commit to ruby/net-imap that referenced this issue Nov 20, 2023
nevans added a commit to ruby/net-imap that referenced this issue Nov 20, 2023
nevans added a commit to ruby/net-imap that referenced this issue Dec 12, 2023
The workaround for #241 (PR #246) also applies to #228.

I haven't seen any evidence of any "real" servers with this exact error
yet.  And the upstream issue (greenmail-mail-test/greenmail#633) was
fixed promptly (thanks!).  So I don't feel that it's critical to be
compatible with it...  But we _do_ need this workaround for #241.  So it
makes sense to at least document this issue in our test fixtures, for
posterity.
nevans added a commit to ruby/net-imap that referenced this issue Dec 12, 2023
The workaround for #241 (PR #246) also applies to #228.

The upstream issue (greenmail-mail-test/greenmail#633) was fixed
promptly (thanks!).  Also, greenmail is a testing fake server and I
haven't seen any evidence of any "real" servers with this exact error
yet.  So I don't feel that it's critical to be compatible with it...
But we _do_ need this workaround for #241.  So it makes sense to at
least document this issue in our test fixtures, for posterity.
nevans added a commit to ruby/net-imap that referenced this issue Dec 12, 2023
The workaround for #241 (PR #246) also applies to #228.

The upstream issue (greenmail-mail-test/greenmail#633) was fixed
promptly (thanks!).  Also, greenmail is a testing fake server and I
haven't seen any evidence of any "real" servers with this exact error
yet.  So I don't feel that it's critical to be compatible with it...
But we _do_ need this workaround for #241.  So it makes sense to at
least document this issue in our test fixtures, for posterity.
nevans added a commit to ruby/net-imap that referenced this issue Dec 12, 2023
The workaround for #241 (PR #246) also applies to #228.

The upstream issue (greenmail-mail-test/greenmail#633) was fixed
promptly (thanks!).  Also, greenmail is a testing fake server and I
haven't seen any evidence of any "real" servers with this exact error
yet.  So I don't feel that it's critical to be compatible with it...
But we _do_ need this workaround for #241.  So it makes sense to at
least document this issue in our test fixtures, for posterity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport_1_6_x Backport to old bugfixing branch 1.6.x backport_2_0_x Backport to branch 2.0.x breaking change bug
Projects
None yet
Development

No branches or pull requests

2 participants