Skip to content

words: index the text of attachments behind a switch (#2166, part 2 of 3) - #2395

Draft
pes0 wants to merge 3 commits into
UCSLabs:mainfrom
pes0:attext-stage1-index
Draft

pes0 wants to merge 3 commits into
UCSLabs:mainfrom
pes0:attext-stage1-index

Conversation

@pes0

@pes0 pes0 commented Dec 6, 2026

Copy link
Copy Markdown

Builds on #2394. Part 2 of 3 for #2166.

Wires attext into the words index, behind a switch that stays off until part 3 adds the option.

  • A part of its own: ATTACHMENT_TEXT = 64 beside ATTACHMENT (the name). texts_full is the full list of what search reads, attachment texts as pieces of their own; texts and texts_with keep their signatures and delegate with none, so no existing caller changes. ALL gains the part: the plain search box finds attachment text, as announced in the issue. attachment: now limits to names and, where extracted, content — easy to split into a keyword of its own if you'd rather.
  • Fingerprints: fingerprint_full(m, attext) is the base fingerprint plus, for a message with attachments and the switch on, the extraction's version (ATTEXT_VERSION) and each attachment's content by its SHA-256 (in memory or kept). Switching the option therefore reads exactly the messages with attachments again; everything else keeps its fingerprint. ATTEXT_VERSION is the knob for "the extractor changed, read again".
  • Both index paths: the background build extracts within attext's caps (attexts_of: bytes from memory or the blobs folder through store::Reader; empty texts dropped). The budgeted in-step read leaves messages with attachments to the background while the switch is on, exactly as it already leaves messages whose hidden words are kept on disk.
  • Words::set_attext(bool) is the switch; part 3 connects it to the option and schedules the pass.
  • One existing test adapted: records_that_lie_are_not_believed used mask 64 as "a part that doesn't exist"; that part exists now, so the lying mask is 128, and a positive assertion checks that 64 is believed.

Tests: cargo test -p mailcraft-model words (34) and -p mailcraft-engine words (48) pass, including a new one for the part and the fingerprint semantics. fmt and clippy clean.

…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 2 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.
@pes0
pes0 force-pushed the attext-stage1-index branch from d791dd3 to 837f716 Compare December 6, 2026 02:02
@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