fkoyer opened a new pull request, #49:
URL: https://github.com/apache/spamassassin/pull/49

   **Target release: 4.0.4** (new plugin loaded via `rules/v404.pre`).
   
   ## Summary
   
   Adds a new `main_body` rule type. A `main_body` rule works like a `body` 
rule,
   but matches only the "main" body: the rendered text of the inline body parts,
   excluding attachments.
   
   Part selection:
   - Named parts (attachments) are skipped.
   - For a `multipart/alternative` section, the one part named by
     `multipart_alternative_preferred_part` is used; when that setting is unset,
     `text/html` is preferred, falling back to `text/plain`.
   - Other multipart containers (e.g. `multipart/mixed`) are descended into, and
     every inline text part they contain is included, in display order.
   
   As with `body` rules, the message Subject is prepended and the same 
whitespace
   normalization is applied, and the text is the full rendered text (including 
any
   text not visible in a mail client). The `multiple`, `maxhits`, and 
`nosubject`
   tflags are supported.
   
   ## Motivation
   
   `body` rules match the concatenated rendered text of every body part of a
   message, including text extracted from attachments (PDFs, images, etc.) and
   every alternative. There is currently no way to write a rule that matches 
only
   the text a mail client would present as the body. `main_body` fills that gap.
   
   ## Implementation
   
   - `Mail::SpamAssassin::Plugin::MainBody` — a self-contained plugin that 
registers
     the `main_body` config keyword and runs the rules, reusing 
`run_generic_tests`
     semantics so scoring, tflags, and meta-rule integration behave like `body`.
   - `Mail::SpamAssassin::Message::get_main_body_parts()` — new shared accessor 
that
     performs the part selection and returns the inline body-part nodes in 
display
     order.
   - `Mail::SpamAssassin::Message::get_main_body_text_array()` — returns the
     concatenated rendered text for the `main_body` rules, reusing the existing 
body
     whitespace-normalization path.
   - `Mail::SpamAssassin::Plugin::BodyEval::vertical_whitespace` is refactored 
to use
     the new shared `get_main_body_parts()` accessor instead of its own inline 
walk.
   - Loaded via `rules/v404.pre`.
   
   ## Testing
   
   Adds `t/main_body.t` (16 subtests): attachment exclusion, the
   `multipart/alternative` default (text/html over text/plain) and override, the
   text/plain fallback, gathering both parts of a `multipart/mixed`, the 
`multiple`
   and `maxhits` tflags, Subject handling with and without `nosubject`, and a 
meta
   rule depending on a `main_body` rule. The full suite (`t/*.t`) passes.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to