Core v0.1: parse, compose, threading, rules, sanitiser, search #1

Open
mnovak wants to merge 0 commits from feature/core-v0.1 into main
Owner

epistula-core v0.1: everything the app does with mail content, pure (no I/O, no clock, no randomness).

Tests (written first, commit c59480a was red with 55 failing): compose 10, mime 16, sanitize 9, thread_rules_search 20 = 55 passed, 0 failed. They include proptest properties: parse never panics on bytes or MIME-like text (512 cases each), safe names are always safe (256), no sanitiser output contains <script, on*= or javascript: (2000), parse(compose(x)) == x (300), threading is order-independent (256), and every query is valid FTS5 (500 + 256, checked in an in-memory SQLite).

Self-review

  • Sanitiser: ammonia allow-list, then : and = in text and attribute values are written as &#58;/&#61;. The literal property can't be met by accident: the corpus and the properties also decode the output and check every tag and attribute semantically (script/iframe/svg tags, on* attributes, javascript:/vbscript:/data:text in URL attributes, CSS that runs or loads). Mutant check: letting every href through makes the corpus test fail.
  • CSS: allow-listed properties only. A declaration is dropped if its value contains url, expression, import, \, comments, quotes or braces. That loses some layouts, but it is safe.
  • <style> blocks are removed entirely, so some newsletters will look plainer. Accepted for V1.
  • mail-builder generates boundaries and Message-IDs from the clock, so compose sets both explicitly. Boundaries are derived from the Message-ID (=_ep_…, a sequence that never occurs in base64 or QP output). compose_is_deterministic checks this.
  • Bcc is never written into the message (tested); the app passes it to SMTP as envelope recipients.
  • Threading's subject fallback is narrow on purpose: only a message with no In-Reply-To and no References, whose subject has a reply or forward prefix, joins the earliest mail with the same subject.
  • Sieve export uses i;unicode-casemap, because Sieve's default comparator folds ASCII case only and the engine folds Czech too.
  • Not covered: S/MIME and PGP parts are treated as ordinary attachments. Bridge decrypts Proton mail before the client sees it.
epistula-core v0.1: everything the app does with mail content, pure (no I/O, no clock, no randomness). **Tests (written first, commit c59480a was red with 55 failing):** compose 10, mime 16, sanitize 9, thread_rules_search 20 = 55 passed, 0 failed. They include proptest properties: parse never panics on bytes or MIME-like text (512 cases each), safe names are always safe (256), no sanitiser output contains `<script`, ` on*=` or `javascript:` (2000), parse(compose(x)) == x (300), threading is order-independent (256), and every query is valid FTS5 (500 + 256, checked in an in-memory SQLite). **Self-review** - Sanitiser: ammonia allow-list, then `:` and `=` in text and attribute values are written as `&#58;`/`&#61;`. The literal property can't be met by accident: the corpus and the properties also decode the output and check every tag and attribute semantically (script/iframe/svg tags, `on*` attributes, `javascript:`/`vbscript:`/`data:text` in URL attributes, CSS that runs or loads). Mutant check: letting every href through makes the corpus test fail. - CSS: allow-listed properties only. A declaration is dropped if its value contains `url`, `expression`, `import`, `\`, comments, quotes or braces. That loses some layouts, but it is safe. - `<style>` blocks are removed entirely, so some newsletters will look plainer. Accepted for V1. - mail-builder generates boundaries and Message-IDs from the clock, so compose sets both explicitly. Boundaries are derived from the Message-ID (`=_ep_…`, a sequence that never occurs in base64 or QP output). `compose_is_deterministic` checks this. - Bcc is never written into the message (tested); the app passes it to SMTP as envelope recipients. - Threading's subject fallback is narrow on purpose: only a message with no In-Reply-To and no References, whose subject has a reply or forward prefix, joins the earliest mail with the same subject. - Sieve export uses `i;unicode-casemap`, because Sieve's default comparator folds ASCII case only and the engine folds Czech too. - Not covered: S/MIME and PGP parts are treated as ordinary attachments. Bridge decrypts Proton mail before the client sees it.
mnovak added 2 commits 2026-11-08 14:11:51 +01:00
This branch is already included in the target branch. There is nothing to merge.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin feature/core-v0.1:feature/core-v0.1
git checkout feature/core-v0.1
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mnovak/EpistulaPublic#1