Skip to content

CAMEL-24419: camel-mail - filter the mail session property namespace on MimeMultipart unmarshal - #25568

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24419
Aug 21, 2026
Merged

CAMEL-24419: camel-mail - filter the mail session property namespace on MimeMultipart unmarshal#25568
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-24419

Conversation

@oscerd

@oscerd oscerd commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Fixes CAMEL-24419.

Problem

CAMEL-23522 extended MailHeaderFilterStrategy so the inbound path also filters the mail.smtp. and mail.smtps. prefixes, not just Camel*/camel*:

String[] inFilter = Arrays.copyOf(CAMEL_FILTER_STARTS_WITH, CAMEL_FILTER_STARTS_WITH.length + 2);
inFilter[CAMEL_FILTER_STARTS_WITH.length] = "mail.smtp.";
inFilter[CAMEL_FILTER_STARTS_WITH.length + 1] = "mail.smtps.";
setInFilterStartsWith(inFilter);

MimeMultipartDataFormat — which CAMEL-23891 gave a header filter for the Camel* namespace — still held a plain DefaultHeaderFilterStrategy, which only knows Camel*/camel*. So the namespace CAMEL-23522 deliberately filters on the consumer path was not filtered by the headersInline unmarshal path. Two entry points into the same component disagreed about the filtered namespace.

Change

One-line swap to MailHeaderFilterStrategy. I checked two things first to keep the blast radius honest:

  1. MailHeaderFilterStrategy.initialize() only calls setInFilterStartsWith(...) — it never touches the out filter, which keeps DefaultHeaderFilterStrategy's field default. Marshal behaviour is unchanged.
  2. The strategy is referenced at exactly one site in the data format: copyNonStandardHeaders()applyFilterToExternalHeaders(), which is the inbound direction.

So the change does precisely one thing: unmarshal now filters the same namespace as the consumer.

Testing

New test sits next to the existing CAMEL-23891 unmarshalInlineHeadersFiltersCamelInternalHeaders. Verified it catches the regression: it fails against the pre-fix code and passes after.

mvn test -Dtest='MimeMultipartDataFormatTest#unmarshalInlineHeadersFiltersMailSessionPropertyHeaders'
mvn clean install -DskipTests    # full reactor, BUILD SUCCESS

Backport

Intended for camel-4.22.x, camel-4.18.x and camel-4.14.x, matching the CAMEL-23891 backports. The upgrade-guide entry stays on main per the project's guide policy.


_Claude Code on behalf of

@oscerd
oscerd requested review from apupier and davsclaus August 21, 2026 18:25
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-mail
  • docs

🔬 Scalpel shadow comparison — Scalpel: 11 tested, 28 compile-only — current: 10 all tested

Maveniverse Scalpel detected 39 affected modules (current approach: 10).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 11 modules (2 direct + 9 downstream), skip tests for 28 (generated code, meta-modules)

Modules Scalpel would test (11)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-mail
  • camel-mail-microsoft-oauth
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
  • docs
Modules with tests skipped (28)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (39 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: Mail
  • Camel :: Mail :: Microsoft OAuth
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — clean, minimal security fix.

This correctly aligns MimeMultipartDataFormat's header filtering with the mail consumer's filtering from CAMEL-23522. Key observations:

  • Strategy swap is correct: MailHeaderFilterStrategy.initialize() only calls setInFilterStartsWith() for the inbound direction, so the marshal/outbound path is unaffected
  • headerFilterStrategy usage is safe: the field is used solely in copyNonStandardHeaders()applyFilterToExternalHeaders() (inbound direction)
  • Case handling: DefaultHeaderFilterStrategy has lowerCase=true by default, so the uppercase MAIL.SMTP.PORT test case works correctly via lowercase comparison
  • Test follows conventions: uses AssertJ, package-private visibility per project standards
  • Upgrade guide entry: well-written with clear migration advice in camel-4x-upgrade-guide-4_23.adoc

All CI checks pass. ✅


AI-generated review — Claude Code on behalf of @gnodet
This review does not replace specialized AI review tools or static analysis.

@oscerd oscerd added the bug Something isn't working label Aug 21, 2026
@oscerd oscerd self-assigned this Aug 21, 2026
@oscerd oscerd added this to the 4.23.0 milestone Aug 21, 2026
…on MimeMultipart unmarshal

CAMEL-23522 extended MailHeaderFilterStrategy so the inbound path also filters
the mail.smtp. and mail.smtps. prefixes, not just Camel*/camel*, so an external
mail message cannot inject JavaMail session properties onto the exchange.

MimeMultipartDataFormat, which CAMEL-23891 gave a header filter for the Camel*
namespace, still held a plain DefaultHeaderFilterStrategy. That strategy only
knows Camel*/camel*, so the namespace CAMEL-23522 deliberately filters on the
consumer path was not filtered by the headersInline unmarshal path.

Switches the data format to MailHeaderFilterStrategy so both entry points agree
on the filtered namespace. The swap is confined to the inbound direction:
MailHeaderFilterStrategy.initialize() only calls setInFilterStartsWith(), so the
out filter keeps the DefaultHeaderFilterStrategy default, and the strategy is
used at exactly one site in the data format (copyNonStandardHeaders, which calls
applyFilterToExternalHeaders). Marshal behaviour is unchanged.

Adds a test next to the existing CAMEL-23891 one, and a 4.23 upgrade-guide entry.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@oscerd
oscerd merged commit c2bcb24 into apache:main Aug 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants