This is an automated email from the ASF dual-hosted git repository.
oscerd pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.14.x by this push:
new e334228e52c8 [backport camel-4.14.x] CAMEL-23516: camel-xmpp - Use
dedicated HeaderFilterStrategy aligned with sibling components
e334228e52c8 is described below
commit e334228e52c8707af362b653181822a5ce39ee04
Author: Andrea Cosentino <[email protected]>
AuthorDate: Tue May 19 11:47:33 2026 +0200
[backport camel-4.14.x] CAMEL-23516: camel-xmpp - Use dedicated
HeaderFilterStrategy aligned with sibling components
Backport of #23283 onto camel-4.14.x. camel-xmpp defaulted its
headerFilterStrategy to a bare DefaultHeaderFilterStrategy (XmppEndpoint
and the XmppBinding no-arg constructor), passing inbound XMPP message
properties — including Camel* / camel* / org.apache.camel.* — onto the
Exchange. Introduces XmppHeaderFilterStrategy (KafkaHeaderFilterStrategy
/ MailHeaderFilterStrategy shape) and switches both defaults to it.
Includes a unit test and the camel-4x-upgrade-guide-4_14.adoc note.
(cherry picked from commit 4a07498a7eccee70f05a80d7c684a35085b8b738)
JIRA: https://issues.apache.org/jira/browse/CAMEL-23516
Closes #23321
---
.../apache/camel/component/xmpp/XmppBinding.java | 3 +-
.../apache/camel/component/xmpp/XmppEndpoint.java | 3 +-
.../component/xmpp/XmppHeaderFilterStrategy.java | 34 ++++++++++++++
.../xmpp/XmppHeaderFilterStrategyTest.java | 53 ++++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_14.adoc | 9 ++++
5 files changed, 98 insertions(+), 4 deletions(-)
diff --git
a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
index b4862547c03f..bf954eed19ac 100644
---
a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
+++
b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppBinding.java
@@ -22,7 +22,6 @@ import java.util.Set;
import org.apache.camel.Exchange;
import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.support.DefaultHeaderFilterStrategy;
import org.apache.camel.util.ObjectHelper;
import org.jivesoftware.smack.packet.DefaultExtensionElement;
import org.jivesoftware.smack.packet.ExtensionElement;
@@ -44,7 +43,7 @@ public class XmppBinding {
private HeaderFilterStrategy headerFilterStrategy;
public XmppBinding() {
- this.headerFilterStrategy = new DefaultHeaderFilterStrategy();
+ this.headerFilterStrategy = new XmppHeaderFilterStrategy();
}
public XmppBinding(HeaderFilterStrategy headerFilterStrategy) {
diff --git
a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
index e1d9cef20393..4d169f195ea7 100644
---
a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
+++
b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppEndpoint.java
@@ -34,7 +34,6 @@ import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
import org.apache.camel.spi.UriPath;
import org.apache.camel.support.DefaultEndpoint;
-import org.apache.camel.support.DefaultHeaderFilterStrategy;
import org.apache.camel.util.ObjectHelper;
import org.apache.camel.util.StringHelper;
import org.jivesoftware.smack.ConnectionConfiguration;
@@ -103,7 +102,7 @@ public class XmppEndpoint extends DefaultEndpoint
implements HeaderFilterStrateg
@UriParam(label = "consumer", defaultValue = "10")
private int connectionPollDelay = 10;
@UriParam(label = "filter")
- private HeaderFilterStrategy headerFilterStrategy = new
DefaultHeaderFilterStrategy();
+ private HeaderFilterStrategy headerFilterStrategy = new
XmppHeaderFilterStrategy();
@UriParam(label = "advanced")
private ConnectionConfiguration connectionConfig;
diff --git
a/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppHeaderFilterStrategy.java
b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppHeaderFilterStrategy.java
new file mode 100644
index 000000000000..cd2b78b25c42
--- /dev/null
+++
b/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppHeaderFilterStrategy.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.apache.camel.support.DefaultHeaderFilterStrategy;
+
+public class XmppHeaderFilterStrategy extends DefaultHeaderFilterStrategy {
+
+ public XmppHeaderFilterStrategy() {
+ initialize();
+ }
+
+ protected void initialize() {
+ setLowerCase(true);
+ // filter headers begin with "Camel" or "org.apache.camel"
+ setOutFilterStartsWith(CAMEL_FILTER_STARTS_WITH);
+ setInFilterStartsWith(CAMEL_FILTER_STARTS_WITH);
+ }
+
+}
diff --git
a/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppHeaderFilterStrategyTest.java
b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppHeaderFilterStrategyTest.java
new file mode 100644
index 000000000000..64718e909210
--- /dev/null
+++
b/components/camel-xmpp/src/test/java/org/apache/camel/component/xmpp/XmppHeaderFilterStrategyTest.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.xmpp;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class XmppHeaderFilterStrategyTest {
+
+ private final XmppHeaderFilterStrategy strategy = new
XmppHeaderFilterStrategy();
+
+ @Test
+ void inboundCamelHeadersAreFiltered() {
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelHttpUri",
"http://evil.example", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("CamelFileName",
"../../etc/passwd", null));
+
assertTrue(strategy.applyFilterToExternalHeaders("CamelBeanMethodName",
"evilMethod", null));
+ }
+
+ @Test
+ void inboundLowercaseCamelHeadersAreFiltered() {
+ assertTrue(strategy.applyFilterToExternalHeaders("camelHttpUri",
"http://evil.example", null));
+ assertTrue(strategy.applyFilterToExternalHeaders("camelfilename",
"../../etc/passwd", null));
+ }
+
+ @Test
+ void outboundCamelHeadersAreFiltered() {
+ assertTrue(strategy.applyFilterToCamelHeaders("CamelHttpUri", "value",
null));
+ assertTrue(strategy.applyFilterToCamelHeaders("camelHttpUri", "value",
null));
+ }
+
+ @Test
+ void nonCamelHeadersPassThrough() {
+ assertFalse(strategy.applyFilterToExternalHeaders("Content-Type",
"application/json", null));
+ assertFalse(strategy.applyFilterToExternalHeaders("X-Request-Id",
"abc-123", null));
+ assertFalse(strategy.applyFilterToCamelHeaders("Content-Type",
"application/json", null));
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
index 63a7060ecbdf..1d1f946ae5b2 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_14.adoc
@@ -298,3 +298,12 @@ aligning the component with the rest of the Camel
component catalog (`camel-kafk
`camel-coap`, `camel-google-pubsub`, ...). Routes that relied on passing
through these header
names from NATS messages can supply a custom `headerFilterStrategy` to restore
the previous
behaviour.
+
+=== camel-xmpp
+
+The default `headerFilterStrategy` is now a new `XmppHeaderFilterStrategy`
that filters headers
+starting with `Camel` / `camel` (case-insensitive) in both the inbound and
outbound directions,
+aligning the component with the rest of the Camel component catalog
(`camel-kafka`, `camel-mail`,
+`camel-coap`, `camel-google-pubsub`, ...). Routes that relied on passing
through these header
+names from XMPP messages can supply a custom `headerFilterStrategy` to restore
the previous
+behaviour.