imap-proto: handle unknown FETCH attributes (RFC 8474 EMAILID/THREADID)#193
Open
x-hannibal wants to merge 3 commits intodjc:mainfrom
Open
imap-proto: handle unknown FETCH attributes (RFC 8474 EMAILID/THREADID)#193x-hannibal wants to merge 3 commits intodjc:mainfrom
x-hannibal wants to merge 3 commits intodjc:mainfrom
Conversation
RFC-compliant servers (Apache James 3.9, Dovecot with OBJECTID plugin, Stalwart) can include extension attributes in FETCH responses that this crate does not yet explicitly support: * RFC 8474 §5 OBJECTID: EMAILID, THREADID * RFC 8514 §2 SAVEDATE (and any future extensions) When any such attribute appears in a FETCH list, msg_att's alt() exhausts all known parsers and nom returns a TakeWhile1 error from the last alternative (response_tagged), causing the entire response to be dropped. Fix: add msg_att_unknown as the last arm of msg_att's alt(). It consumes: - a single-level parenthesised value (EMAILID (Mxxx), THREADID (Txxx)) - an nstring (THREADID NIL, SAVEDATE "date-time") - a bare atom / number (fallback for scalar values) and returns AttributeValue::Unknown so the rest of the FETCH attribute list can be parsed without error. The name and raw value are discarded; callers that need the actual value should open a dedicated tracking issue. Four new tests cover: EMAILID, THREADID, THREADID NIL, EMAILID+THREADID combined in the same FETCH response. All 86 existing tests still pass.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #193 +/- ##
==========================================
+ Coverage 76.35% 76.71% +0.36%
==========================================
Files 21 21
Lines 2829 2847 +18
==========================================
+ Hits 2160 2184 +24
+ Misses 669 663 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RFC-compliant IMAP servers can include extension attributes in
FETCHresponses thatimap-protodoes not yet explicitly support. Known cases:EMAILID,THREADID— sent by Apache James 3.9, Dovecot (with OBJECTID plugin), and othersSAVEDATEWhen one of these attributes appears in a
FETCHlist,msg_att'salt()exhausts all known parsers. Because nom 7'saltreturns the last alternative's error (not the deepest), the caller sees aTakeWhile1error fromresponse_tagged'simap_tag— which tries to match*as a tag character and fails. The entire response is dropped.Fix
Add
msg_att_unknownas the last arm ofmsg_att'salt(). It consumes:(...)— coversEMAILID (Mxxx),THREADID (Txxx)THREADID NIL,SAVEDATE "date-time"and returns
AttributeValue::Unknownso the rest of theFETCHattribute list can be parsed without error.AttributeValue::Unknownis added to the enum as a documented variant. The name and raw value are consumed and discarded; callers that need the actual value for a specific extension should open a dedicated tracking issue or PR to add first-class support.Tests
Four new tests in
parser/tests.rs:test_fetch_rfc8474_emailidEMAILID (Mxxx)alongsideUID+BODY[]<0>test_fetch_rfc8474_threadidTHREADID (Txxx)alongsideUID+BODY[]<0>test_fetch_rfc8474_threadid_nilTHREADID NIL(RFC 8474 §5.2 allows NIL)test_fetch_rfc8474_emailid_and_threadidFETCHresponseAll 86 existing tests continue to pass.
Notes
msg_att_unknownis intentionally the last alternative so it never shadows an explicitly supported attribute.