Skip to content

options: Search the text of attachments, off by default (#2166, part 3 of 3) - #2396

Draft
pes0 wants to merge 5 commits into
UCSLabs:mainfrom
pes0:attext-stage1-option
Draft

pes0 wants to merge 5 commits into
UCSLabs:mainfrom
pes0:attext-stage1-option

Conversation

@pes0

@pes0 pes0 commented Dec 6, 2026

Copy link
Copy Markdown

Builds on #2395. Part 3 of 3 for #2166 — with this the stage-1 stack is complete.

The user-facing switch, off by default:

  • File › Options › Mail → "Search the text of attachments", with a hover text saying what it reads (Office documents and plain text), that it is bounded per file, and that the first pass over a large mailbox takes a while.
  • The pref indexAttachmentText (#[serde(default)]: settings written before the option read as off; a round-trip test covers the command, the serialization, and the old-settings case).
  • file.options takes the key (params documented) and, when the value changed, starts the pass at once: words_in_step hands the pref to Words::set_attext on every tick, and because fingerprint_full changes with the switch for exactly the messages that have attachments, those are read again — everything else keeps its words and is not touched.
  • i18n: the two new strings are extracted into every catalogue (cargo xtask i18n).
  • Release notes: packaging/release-notes.d/new/2166.md.

cargo check/clippy clean for mailcraft-engine and mailcraft-ui-egui; the new test and the existing words/options tests pass.

The stack: #2394 (extractor) ← #2395 (index) ← this. Happy to squash or split differently if you prefer.

…Labs#2166)

Stage 1, part 1 of the attachment-content search: a bounded, panic-free
reader for OOXML containers (ECMA-376/APPNOTE: end of central directory,
central directory, local headers; stored and deflate members) and the
main parts of DOCX/XLSX/PPTX, with XML character data resolved through
quick-xml; plain-text formats decode through mailcraft-charset. Caps on
input, members, decompressed bytes and kept text; a hostile file is an
error, never a stop. Fuzz target included. No PDF (stage 2), no index
wiring yet (part 2).
@coderabbitai

coderabbitai Bot commented Dec 6, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

pes0 added 3 commits December 6, 2026 03:02
guess decodes (UTF-8, else Windows-1252) and is used as such; the text
cap counts characters; a document without its main part is refused;
only block ends (p, tr, tc, si, row) separate words, so a run Word
splits mid-word stays one; CDATA is read; an end-of-central-directory
candidate is believed only when what it says holds; every offset
computation is checked; the module's contract says what a malformed
document part yields. Five tests cover the new behaviour.
Stage 1, part 2: a new part ATTACHMENT_TEXT next to the attachment's
name; texts_full carries the extracted texts (texts and texts_with are
unchanged for their callers); attachment: finds names and, where
extracted, content. fingerprint_full adds the extraction's version and
each attachment's content to the fingerprint when the switch is on, so
exactly the messages with attachments are read again when it changes;
without attachments the fingerprint is the base one. The budgeted
in-step read leaves messages with attachments to the background, as it
does hidden words kept on disk; the background extracts within
attext's caps. Words::set_attext is the switch; the option and its
backfill follow in part 3.
Stage 1, part 3: File > Options > Mail gains the switch. It is the pref
indexAttachmentText (settings from before read as off), file.options
takes it and starts the pass at once: the fingerprints of messages with
attachments change with the switch, so exactly those are read again,
bounded per file by attext's caps; everything else keeps its words.
The catalogues carry the two new strings; a release-note fragment says
it in a line.
@pes0
pes0 force-pushed the attext-stage1-option branch from f076f20 to 3d14d98 Compare December 6, 2026 02:02
…bs#2166)

The second review's two findings: a sheet's cells and their inline
strings separate words like its rows do (Alpha and Beta in adjacent
cells stay two words), and the end-of-directory candidate's offset is
only read once it is known to lie inside the data, so a 32-bit build
can't overflow on what a record claims. Two tests.
@github-actions

github-actions Bot commented Dec 6, 2026

Copy link
Copy Markdown

One step left: sign the Contributor Licence Agreement

Thank you for contributing. Before this can be merged, everyone listed below signs the CLA once. It takes one comment, and it covers every contribution you make from now on.

To sign: add a new comment to this pull request with only this line in it (the copy button is on the right):

I have read the MailCraft CLA and I agree to it.

This check turns green within a minute or so. Editing an older comment doesn't count, so please post a new one.

Still to sign:

You keep the copyright in your work, and MailCraft stays MIT OR Apache-2.0. The CLA also lets UCS Care Group release MailCraft under other terms, such as a commercial edition, without asking each contributor again. Questions are welcome here.

@sonarqubecloud

sonarqubecloud Bot commented Dec 6, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant