Andrea Cosentino created CAMEL-24423:
----------------------------------------
Summary: camel-tika - parsed document metadata is copied to
exchange headers without filtering
Key: CAMEL-24423
URL: https://issues.apache.org/jira/browse/CAMEL-24423
Project: Camel
Issue Type: Bug
Components: camel-tika
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.23.0
TikaProducer.convertMetadataToHeaders() copies every metadata name produced by
the Tika parse straight onto the Camel message:
{code:java}
private void convertMetadataToHeaders(Metadata metadata, Exchange exchange) {
if (metadata != null) {
for (String metaname : metadata.names()) {
String[] values = metadata.getValues(metaname);
if (values.length == 1) {
exchange.getIn().setHeader(metaname, values[0]);
} else {
exchange.getIn().setHeader(metaname, values);
}
}
}
}
{code}
The metadata names come from the parsed document, which is the message body.
There is no HeaderFilterStrategy and no prefixing, so a document whose metadata
declares a name inside the Camel-internal namespace sets that internal header
on the exchange. Every other component that maps externally-derived names into
the header map applies an inbound HeaderFilterStrategy for exactly this reason.
Proposal: in convertMetadataToHeaders(), either reject names matching
Camel*/camel*/org.apache.camel.* or prefix all parsed metadata (for example
with "tika."), and document the choice. Prefixing is the more predictable
option but is a breaking change for routes reading the current names, so it
needs an upgrade-guide entry; filtering the internal namespace only is the
smaller change.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)