Email/get: header:List-Id:asText returns null #642

Closed
opened 2026-11-25 20:13:59 +00:00 by jcoffey-dev · 0 comments
Owner

Email/get returns null for header:List-Id:asText on a message that has a List-Id header. The raw form returns the value:

["Email/get", {"accountId": "…", "ids": ["…"],
  "properties": ["header:List-Id", "header:List-Id:asText"]}, "g"]
{"header:List-Id": " JSON Meta Access Protocol <jmap.ietf.org>",
 "header:List-Id:asText": null}

RFC 8621 §4.1.2.3 allows asText for List-Id, so this should return the decoded text, JSON Meta Access Protocol <jmap.ietf.org>. Seen on a message posted to an IETF list (the jmap list, relayed through dmarc.ietf.org).

Cause. In crates/email/src/message/headers.rs (header_value), a header the parser treats as structured is not re-read from the raw bytes. List-Id comes out of the parser as a structured value, and into_form(&HeaderForm::Text) has no arm for that value, so it falls through to Null. Only unstructured headers, or :asRaw, take the raw-bytes path that calls parse_unstructured().

Fix. When the requested form is Text and the parsed value isn't Text/TextList, re-parse the raw header bytes with parse_unstructured(), the way an unstructured header is handled.

Related, same function: header:From:asText also returns null. RFC 8621 doesn't allow asText on From (it's an address header), so the request should be rejected with invalidArguments, not answered with null. It's worth checking the form/header combinations the RFC rules out (§4.1.2) and rejecting them.

A client that asks for asText gets nothing back and can't tell an absent header from a wrong answer, so a filter preview or a list-based view silently treats list mail as non-list mail.

`Email/get` returns `null` for `header:List-Id:asText` on a message that has a List-Id header. The raw form returns the value: ```json ["Email/get", {"accountId": "…", "ids": ["…"], "properties": ["header:List-Id", "header:List-Id:asText"]}, "g"] ``` ```json {"header:List-Id": " JSON Meta Access Protocol <jmap.ietf.org>", "header:List-Id:asText": null} ``` RFC 8621 §4.1.2.3 allows `asText` for List-Id, so this should return the decoded text, `JSON Meta Access Protocol <jmap.ietf.org>`. Seen on a message posted to an IETF list (the jmap list, relayed through dmarc.ietf.org). **Cause.** In `crates/email/src/message/headers.rs` (`header_value`), a header the parser treats as structured is not re-read from the raw bytes. List-Id comes out of the parser as a structured value, and `into_form(&HeaderForm::Text)` has no arm for that value, so it falls through to `Null`. Only unstructured headers, or `:asRaw`, take the raw-bytes path that calls `parse_unstructured()`. **Fix.** When the requested form is `Text` and the parsed value isn't `Text`/`TextList`, re-parse the raw header bytes with `parse_unstructured()`, the way an unstructured header is handled. **Related, same function:** `header:From:asText` also returns `null`. RFC 8621 doesn't allow `asText` on From (it's an address header), so the request should be rejected with `invalidArguments`, not answered with `null`. It's worth checking the form/header combinations the RFC rules out (§4.1.2) and rejecting them. A client that asks for `asText` gets nothing back and can't tell an absent header from a wrong answer, so a filter preview or a list-based view silently treats list mail as non-list mail.
jcoffey-dev added this to the 27.1 milestone 2026-11-25 20:15:40 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: inbuxa/inbuxa-server#642