-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat: Implement METADATA
#432
Comments
SORT/THREAD is next. Then CONDSTORE/QRESYNC. METADATA doesn't look too complicated. But the devil may be in the detail. Are you in a position to draft something up? :-) If not, I can take a look in a few weeks. |
capability =/ "METADATA" / "METADATA-SERVER"
command-auth =/ setmetadata / getmetadata
; empty string for mailbox implies server annotation.
setmetadata = "SETMETADATA" SP mailbox SP entry-values
entry-values = "(" entry-value *(SP entry-value) ")"
entry-value = entry SP value
; Slash-separated path to entry. MUST NOT contain "*" or "%".
; TODO(damian): astring allows "*" and "%". We could use a `Wrapper(AString)`?
entry = astring
value = nstring / literal8
; empty string for mailbox implies server annotation.
getmetadata = "GETMETADATA" [SP getmetadata-options] SP mailbox SP entries
getmetadata-options = "(" getmetadata-option *(SP getmetadata-option) ")"
; tagged-ext-label and tagged-ext-val are defined in [RFC4466].
; TODO(damian):
; See discussion in https://github.com/duesee/imap-codec/pull/417
; TLDR;
; I think we don't want to support a "generic" syntax. Only implement `maxsize-opt` and `scope-opt` from below?
getmetadata-option = tagged-ext-label [SP tagged-ext-val]
; Used as a getmetadata-option
maxsize-opt = "MAXSIZE" SP number
; Used as a getmetadata-option
scope-opt = "DEPTH" SP ("0" / "1" / "infinity")
entries = entry / "(" entry *(SP entry) ")"
response-payload =/ metadata-resp
; empty string for mailbox implies server annotation.
metadata-resp = "METADATA" SP mailbox SP (entry-values / entry-list)
entry-list = entry *(SP entry) resp-text-code =/ "METADATA" SP (
"LONGENTRIES" SP number /
"MAXSIZE" SP number /
"TOOMANY" /
"NOPRIVATE"
) Quirks
|
I am currently fixing metadata parsing in imap-proto: djc/tokio-imap#159 Offtopic: is it true that imap-codec tolerates garbage responses, e.g. received line |
Short answer: no. I'm not sure how tolerating garbage in IMAP could work. IMAP doesn't really have "tokens" we can detect. Simon, the The best one could do is to detect lines and literals. But even then, this is asking for issues. Example:
If we discard the first line, the next lines could be interpreted as server data. It's not predictable. I would prefer to only discard/ignore data when we are absolutely sure we know where to safely chime in again in the byte stream. Do you have a real-world example of a server sending garbage? I don't mean unknown codes or something that can be detected. But things similar to your |
Most recent example is mail.163.com sends Another example was outlook server adding whitespace at the end of the line. |
Thoughts:
That's unfortunate. The workaround is non-trivial because it would either require allowing an empty list (which would spread the incompatibility) or dropping the message (which would require additional logic). Was this already reported to mail.163.com? Can't they just stop sending this?
Was this already reported to Microsoft? Workaround is easy and can be done w/o the risk to reproduce the fault (or changing semantics). Mental note: It's the third time I see an open-source project implementing a workaround for exactly this issue, which, basically, should require Microsoft deleting a single character. |
Hey @link2xt! Do you have an example how you use the metadata extension? I'm having a bit of a hard time figuring out how to present the entries to users. Currently, it's just an The RFC is not totally clear to me. Any suggestions or experience? |
We currently only get |
Small update @link2xt: I talked with Arnt Gulbrandsen and asked him about ignoring/dropping bad messages. In practice, it may be safe to consume a line, see if it ends with Funnily, I used this (seemingly hacky) approach already when implementing a server¹. But I changed it due to the danger of ambiguities (and possible injection attacks). There are cases where TLDR; It's possible to realiably split an IMAP stream into fragments w/o doing IMAP parsing. Thus, ¹ https://github.com/Email-Analysis-Toolkit/fake-mail-server |
There is currently no support for METADATA extension.
Encoding SETMETADATA command and decoding METADATA responses returned for GETMETADATA commands does not seem to be possible currently.
The text was updated successfully, but these errors were encountered: