Email/get: header:List-Id:asText returns the text #644

Merged
jcoffey-dev merged 1 commits from fix/642-list-id-astext into main 2026-11-25 20:47:28 +00:00
Owner

header:List-Id:asText answered null for a message that has a List-Id header (#642). mail-parser parses List-Id as an address, and into_form(Text) has no conversion from an address, so the value fell through to Null. The raw-bytes path that reads unstructured text was only taken for unstructured headers or asRaw.

Now, when asText is asked for and the stored value isn't text, the raw header is read again with parse_unstructured(), in both header_to_value implementations (parsed message and stored metadata). Text values (Subject and others) take the same path as before.

inbuxa-webmail asks for header:List-Id:asText, so this also fixes its mailing-list detection.

Tests: structured_headers_as_text_from_the_parsed_message and structured_headers_as_text_from_stored_metadata (List-Id, an encoded Subject, List-Help as text; raw List-Id unchanged). cargo test -p email --lib passes, cargo fmt --all --check is clean, and the fork checks pass.

Not in this PR: refusing forms RFC 8621 §4.1.2 doesn't allow (e.g. header:From:asText) with invalidArguments instead of null. ihasmail still asks for header:List-Unsubscribe:asText, so that check would fail its Email/get against inbuxa outright; it's filed separately for 27.7.

Fixes #642

`header:List-Id:asText` answered `null` for a message that has a List-Id header (#642). mail-parser parses List-Id as an address, and `into_form(Text)` has no conversion from an address, so the value fell through to `Null`. The raw-bytes path that reads unstructured text was only taken for unstructured headers or `asRaw`. Now, when `asText` is asked for and the stored value isn't text, the raw header is read again with `parse_unstructured()`, in both `header_to_value` implementations (parsed message and stored metadata). Text values (Subject and others) take the same path as before. inbuxa-webmail asks for `header:List-Id:asText`, so this also fixes its mailing-list detection. Tests: `structured_headers_as_text_from_the_parsed_message` and `structured_headers_as_text_from_stored_metadata` (List-Id, an encoded Subject, List-Help as text; raw List-Id unchanged). `cargo test -p email --lib` passes, `cargo fmt --all --check` is clean, and the fork checks pass. Not in this PR: refusing forms RFC 8621 §4.1.2 doesn't allow (e.g. `header:From:asText`) with `invalidArguments` instead of `null`. ihasmail still asks for `header:List-Unsubscribe:asText`, so that check would fail its Email/get against inbuxa outright; it's filed separately for 27.7. Fixes #642
jcoffey-dev added 1 commit 2026-11-25 20:29:46 +00:00
Email/get: header:<name>:asText for headers parsed as non-text
ci / fork-checks (pull_request) Skipped
ci / build (pull_request) Skipped
github/ci (branch) GitHub Actions
ci / github (pull_request) Successful in 17m27s
ce0880abc9
List-Id is parsed as an address, and asText had no conversion from
that, so header:List-Id:asText answered null even when the message had
the header. When asText is asked for and the stored value isn't text,
read the raw header again as unstructured text, in both the parsed and
the stored-metadata paths.

Fixes #642
jcoffey-dev merged commit 5ccb2da0a0 into main 2026-11-25 20:47:28 +00:00
jcoffey-dev deleted branch fix/642-list-id-astext 2026-11-25 20:47:28 +00:00
Sign in to join this conversation.