Skip to content

Conversation

@nevans
Copy link
Collaborator

@nevans nevans commented Nov 6, 2020

In RFC3501, capability-data is found both in response-data and in
resp-text-code. Many IMAP servers return CAPABILITY codes in the
server greeting or in the tagged OK for STARTTLS, LOGIN, or
AUTHENTICATE.

This adds parsing for CAPABILITY data in a ResponseCode, the same as
already existed for CAPABILITY data in an UntaggedResponse.

This also fixes resp-text to properly match the text that comes after a
resp-text-code. The extra SP has been removed.

n.b. I submitted this PR previously, before net-imap was gemified:

@nevans nevans force-pushed the CAPABILITY-in-response-code branch 3 times, most recently from 98adfdb to 27a7f27 Compare November 8, 2020 14:29
@nevans nevans force-pushed the CAPABILITY-in-response-code branch from 27a7f27 to fe77596 Compare December 7, 2020 08:39
nevans and others added 4 commits December 8, 2020 22:42
`accept` can be used to replace `lookahead` + check `token.symbol` +
`shift_token`.  It's not being used here, but has been separated out
into its own commit to reduce merge conflicts from multiple branches
which use it.
`astring_chars` roughly matches the RFC2060 definition of `atom`, and is
used by RFC3501's `astring`.  `atom` matches the RFC3501 definition.
Although nothing in the parser currently uses `atom`, future commits
will update use it where it's used by RFC3501, RFC4466, etc.

Made a helper method, `combine_adjacent` which is used by both `atom`
and `astring_chars` to combine adjacent tokens into a single string.

It would probably be better to update the lexer regexps, possibly
using negative lookahead assertions, so that it returns a single token.
In RFC3501, "capability-data" is found both in "response-data" and in
"resp-text-code".  Many IMAP servers return CAPABILITY codes in the
server greeting or in the tagged OK for STARTTLS, LOGIN, or
AUTHENTICATE.

This adds parsing for CAPABILITY data in a ResponseCode, the same as
already existed for CAPABILITY data in an UntaggedResponse.
A minor annoyance. :)

The RFC3501 ABNF implies that the "text" we are concerned with comes
after the space:
   resp-text       = ["[" resp-text-code "]" SP] text
@nevans nevans force-pushed the CAPABILITY-in-response-code branch from fe77596 to fc14be6 Compare December 10, 2020 23:21
@shugo shugo merged commit c8c1a25 into ruby:master Mar 9, 2021
@shugo
Copy link
Member

shugo commented Mar 9, 2021

@nevans I've merged it. Thank you!

@nevans nevans deleted the CAPABILITY-in-response-code branch April 22, 2021 21:14
@nevans nevans added the IMAP4rev1 Requirement for IMAP4rev1, RFC3501 label Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IMAP4rev1 Requirement for IMAP4rev1, RFC3501

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants