This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch CAMEL-27250-docling-output-path
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ce013b6f30791a7fb9a78bb6adb83dd547f1b896
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Nov 19 15:33:48 2026 +0100

    CAMEL-27250: camel-docling - the CamelDoclingOutputFilePath header must be 
a relative path unless outputBaseDirectory is set
    
    Without outputBaseDirectory, the CamelDoclingOutputFilePath header was only 
normalized, so it could name any
    directory for the docling CLI output. It must now be a relative path that 
does not start with ../ once
    normalized, the same rule as for the custom arguments; otherwise the 
exchange fails with an IOException.
    With outputBaseDirectory set, nothing changes. Routes that use absolute 
output directories set
    outputBaseDirectory to a directory that contains them (upgrade guide 4.24).
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../apache/camel/catalog/components/docling.json   |  4 +--
 .../camel/catalog/docs/docling-component.adoc      | 18 +++++++----
 .../apache/camel/component/docling/docling.json    |  4 +--
 .../src/main/docs/docling-component.adoc           | 18 +++++++----
 .../component/docling/DoclingConfiguration.java    |  5 ++--
 .../camel/component/docling/DoclingProducer.java   | 24 ++++++++++-----
 .../docling/DoclingOutputPathValidationTest.java   | 35 +++++++++++++++++++---
 .../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc    | 11 +++++++
 .../dsl/DoclingComponentBuilderFactory.java        |  7 +++--
 .../dsl/DoclingEndpointBuilderFactory.java         | 21 +++++++------
 10 files changed, 106 insertions(+), 41 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
index a3e3e8297802..2df8ad2ce3dd 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/docling.json
@@ -81,7 +81,7 @@
     "inputBaseDirectory": { "index": 54, "kind": "property", "displayName": 
"Input Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, every local 
input file path must resolve inside this directory once normalize [...]
     "maxFileSize": { "index": 55, "kind": "property", "displayName": "Max File 
Size", "group": "security", "label": "security", "required": false, "type": 
"integer", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 52428800, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "Maximum file size in 
bytes for processing" },
     "oauthProfile": { "index": 56, "kind": "property", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials grant. When se 
[...]
-    "outputBaseDirectory": { "index": 57, "kind": "property", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this dir [...]
+    "outputBaseDirectory": { "index": 57, "kind": "property", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this dir [...]
   },
   "headers": {
     "CamelDoclingOperation": { "index": 0, "kind": "header", "displayName": 
"", "group": "common", "label": "", "required": false, "javaType": 
"org.apache.camel.component.docling.DoclingOperations", "enum": [ 
"CONVERT_TO_MARKDOWN", "CONVERT_TO_HTML", "CONVERT_TO_JSON", "EXTRACT_TEXT", 
"EXTRACT_STRUCTURED_DATA", "SUBMIT_ASYNC_CONVERSION", 
"CHECK_CONVERSION_STATUS", "BATCH_CONVERT_TO_MARKDOWN", 
"BATCH_CONVERT_TO_HTML", "BATCH_CONVERT_TO_JSON", "BATCH_EXTRACT_TEXT", 
"BATCH_EXTRACT_STRUCTURE [...]
@@ -202,6 +202,6 @@
     "inputBaseDirectory": { "index": 72, "kind": "parameter", "displayName": 
"Input Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, every local 
input file path must resolve inside this directory once normaliz [...]
     "maxFileSize": { "index": 73, "kind": "parameter", "displayName": "Max 
File Size", "group": "security", "label": "security", "required": false, 
"type": "integer", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 52428800, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "Maximum file size in 
bytes for processing" },
     "oauthProfile": { "index": 74, "kind": "parameter", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials grant. When s 
[...]
-    "outputBaseDirectory": { "index": 75, "kind": "parameter", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this di [...]
+    "outputBaseDirectory": { "index": 75, "kind": "parameter", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this di [...]
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/docling-component.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/docling-component.adoc
index 4b1b9e9337e9..42e1dde0f028 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/docling-component.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/docling-component.adoc
@@ -157,7 +157,7 @@ directory-or-file `String` body accepted by the batch 
operations.
 | `outputBaseDirectory`
 | _(none)_
 | When set, the output directory passed to the docling CLI must resolve inside 
this directory once normalized.
-Applies to the `CamelDoclingOutputFilePath` header.
+Applies to the `CamelDoclingOutputFilePath` header. When not set, that header 
must be a relative path.
 |===
 
 With both options left at their defaults, a body that is neither a URL nor a 
path is written to a temporary
@@ -169,9 +169,15 @@ Typed bodies - `File`, `byte[]`, `InputStream`, and the 
explicit path collection
 operations - are unambiguous and are likewise unaffected.
 
 The `CamelDoclingOutputFilePath` header, which selects the CLI `--output` 
directory, is normalized lexically
-and, when `outputBaseDirectory` is set, confined to that directory. The 
normalization applies unconditionally;
-with `outputBaseDirectory` unset, a header value without traversal segments is 
otherwise used as given. The
-containment is lexical and does not resolve symbolic links (as with 
`inputBaseDirectory`).
+and then checked:
+
+- With `outputBaseDirectory` set, a relative value is resolved against that 
directory, and the result must
+stay inside it. An absolute value is accepted when it is inside the directory.
+- With `outputBaseDirectory` unset, the value must be a relative path that 
does not start with `../` once
+normalized, the same rule as for the custom arguments. It resolves against the 
CLI working directory. To use
+absolute output directories, set `outputBaseDirectory` to a directory that 
contains them.
+
+The checks are lexical and do not resolve symbolic links (as with 
`inputBaseDirectory`).
 
 [source,java]
 ----
@@ -502,8 +508,8 @@ Only the following flags are permitted:
 |===
 
 The `--output` (`-o`) flag is **not permitted** because the output directory 
is managed by the producer.
-Use the `CamelDoclingOutputFilePath` header or endpoint configuration instead. 
That header is normalized and,
-when `outputBaseDirectory` is set, confined to that directory (see the 
security options above).
+Use the `CamelDoclingOutputFilePath` header or endpoint configuration instead. 
That header must be a relative
+path, or, when `outputBaseDirectory` is set, a path inside that directory (see 
the security options above).
 
 Additionally, the following are rejected:
 
diff --git 
a/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
 
b/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
index a3e3e8297802..2df8ad2ce3dd 100644
--- 
a/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
+++ 
b/components/camel-ai/camel-docling/src/generated/resources/META-INF/org/apache/camel/component/docling/docling.json
@@ -81,7 +81,7 @@
     "inputBaseDirectory": { "index": 54, "kind": "property", "displayName": 
"Input Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, every local 
input file path must resolve inside this directory once normalize [...]
     "maxFileSize": { "index": 55, "kind": "property", "displayName": "Max File 
Size", "group": "security", "label": "security", "required": false, "type": 
"integer", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 52428800, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "Maximum file size in 
bytes for processing" },
     "oauthProfile": { "index": 56, "kind": "property", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials grant. When se 
[...]
-    "outputBaseDirectory": { "index": 57, "kind": "property", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this dir [...]
+    "outputBaseDirectory": { "index": 57, "kind": "property", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this dir [...]
   },
   "headers": {
     "CamelDoclingOperation": { "index": 0, "kind": "header", "displayName": 
"", "group": "common", "label": "", "required": false, "javaType": 
"org.apache.camel.component.docling.DoclingOperations", "enum": [ 
"CONVERT_TO_MARKDOWN", "CONVERT_TO_HTML", "CONVERT_TO_JSON", "EXTRACT_TEXT", 
"EXTRACT_STRUCTURED_DATA", "SUBMIT_ASYNC_CONVERSION", 
"CHECK_CONVERSION_STATUS", "BATCH_CONVERT_TO_MARKDOWN", 
"BATCH_CONVERT_TO_HTML", "BATCH_CONVERT_TO_JSON", "BATCH_EXTRACT_TEXT", 
"BATCH_EXTRACT_STRUCTURE [...]
@@ -202,6 +202,6 @@
     "inputBaseDirectory": { "index": 72, "kind": "parameter", "displayName": 
"Input Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, every local 
input file path must resolve inside this directory once normaliz [...]
     "maxFileSize": { "index": 73, "kind": "parameter", "displayName": "Max 
File Size", "group": "security", "label": "security", "required": false, 
"type": "integer", "javaType": "long", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 52428800, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "Maximum file size in 
bytes for processing" },
     "oauthProfile": { "index": 74, "kind": "parameter", "displayName": "Oauth 
Profile", "group": "security", "label": "security", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "OAuth profile name for 
obtaining an access token via the OAuth 2.0 Client Credentials grant. When s 
[...]
-    "outputBaseDirectory": { "index": 75, "kind": "parameter", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this di [...]
+    "outputBaseDirectory": { "index": 75, "kind": "parameter", "displayName": 
"Output Base Directory", "group": "security", "label": "security", "required": 
false, "type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "configurationClass": 
"org.apache.camel.component.docling.DoclingConfiguration", 
"configurationField": "configuration", "description": "When set, the output 
directory passed to the docling CLI must resolve inside this di [...]
   }
 }
diff --git 
a/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc 
b/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc
index 4b1b9e9337e9..42e1dde0f028 100644
--- a/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc
+++ b/components/camel-ai/camel-docling/src/main/docs/docling-component.adoc
@@ -157,7 +157,7 @@ directory-or-file `String` body accepted by the batch 
operations.
 | `outputBaseDirectory`
 | _(none)_
 | When set, the output directory passed to the docling CLI must resolve inside 
this directory once normalized.
-Applies to the `CamelDoclingOutputFilePath` header.
+Applies to the `CamelDoclingOutputFilePath` header. When not set, that header 
must be a relative path.
 |===
 
 With both options left at their defaults, a body that is neither a URL nor a 
path is written to a temporary
@@ -169,9 +169,15 @@ Typed bodies - `File`, `byte[]`, `InputStream`, and the 
explicit path collection
 operations - are unambiguous and are likewise unaffected.
 
 The `CamelDoclingOutputFilePath` header, which selects the CLI `--output` 
directory, is normalized lexically
-and, when `outputBaseDirectory` is set, confined to that directory. The 
normalization applies unconditionally;
-with `outputBaseDirectory` unset, a header value without traversal segments is 
otherwise used as given. The
-containment is lexical and does not resolve symbolic links (as with 
`inputBaseDirectory`).
+and then checked:
+
+- With `outputBaseDirectory` set, a relative value is resolved against that 
directory, and the result must
+stay inside it. An absolute value is accepted when it is inside the directory.
+- With `outputBaseDirectory` unset, the value must be a relative path that 
does not start with `../` once
+normalized, the same rule as for the custom arguments. It resolves against the 
CLI working directory. To use
+absolute output directories, set `outputBaseDirectory` to a directory that 
contains them.
+
+The checks are lexical and do not resolve symbolic links (as with 
`inputBaseDirectory`).
 
 [source,java]
 ----
@@ -502,8 +508,8 @@ Only the following flags are permitted:
 |===
 
 The `--output` (`-o`) flag is **not permitted** because the output directory 
is managed by the producer.
-Use the `CamelDoclingOutputFilePath` header or endpoint configuration instead. 
That header is normalized and,
-when `outputBaseDirectory` is set, confined to that directory (see the 
security options above).
+Use the `CamelDoclingOutputFilePath` header or endpoint configuration instead. 
That header must be a relative
+path, or, when `outputBaseDirectory` is set, a path inside that directory (see 
the security options above).
 
 Additionally, the following are rejected:
 
diff --git 
a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
 
b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
index 35494251f4c1..890801b9ddcc 100644
--- 
a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
+++ 
b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingConfiguration.java
@@ -96,8 +96,9 @@ public class DoclingConfiguration implements Cloneable {
     @Metadata(description = "When set, the output directory passed to the 
docling CLI must resolve inside this"
                             + " directory once normalized. Applies to the 
CamelDoclingOutputFilePath header. The"
                             + " check is lexical and does not resolve symbolic 
links, matching inputBaseDirectory."
-                            + " When empty, no directory restriction is 
applied and the header value is only"
-                            + " normalized.")
+                            + " When empty, the header value must be a 
relative path that does not leave the"
+                            + " working directory once normalized; set this 
option to use absolute output"
+                            + " directories.")
     private String outputBaseDirectory;
 
     @UriParam
diff --git 
a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
 
b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
index 206d5b3dfa61..e526d37d1c11 100644
--- 
a/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
+++ 
b/components/camel-ai/camel-docling/src/main/java/org/apache/camel/component/docling/DoclingProducer.java
@@ -2398,19 +2398,29 @@ public class DoclingProducer extends DefaultProducer {
     }
 
     /**
-     * Normalizes the given output directory and, when {@code 
outputBaseDirectory} is configured, verifies that it stays
-     * inside that directory. Mirrors {@link 
#resolveWithinInputBaseDirectory(String)} so that the output directory
-     * carried by the {@link DoclingHeaders#OUTPUT_FILE_PATH} header receives 
the same treatment as input paths. The
-     * containment check is lexical: symbolic links are not resolved, so - like
+     * Normalizes the given output directory and verifies where it may point. 
When {@code outputBaseDirectory} is
+     * configured, the directory must stay inside it, as {@link 
#resolveWithinInputBaseDirectory(String)} does for input
+     * paths. Without it, the directory must be a relative path that does not 
leave the CLI working directory, the same
+     * rule as for the custom arguments. The checks are lexical: symbolic 
links are not resolved, so - like
      * {@link #resolveWithinInputBaseDirectory(String)} - a symlink inside the 
base directory that points outside it is
      * not detected.
      */
     private Path resolveWithinOutputBaseDirectory(String outputPath) throws 
IOException {
         String base = configuration.getOutputBaseDirectory();
         if (base == null || base.isEmpty()) {
-            // no directory restriction: normalize lexically only, and leave 
relative paths relative so that they keep
-            // resolving the way they did before - against the CLI working 
directory, when one is set
-            return Paths.get(outputPath).normalize();
+            // no base directory: only a relative path that stays relative 
after normalizing, so that it keeps resolving
+            // against the CLI working directory, when one is set
+            Path path = Paths.get(outputPath).normalize();
+            if (path.isAbsolute() || path.getRoot() != null) {
+                throw new IOException(
+                        "Output path must be a relative path when 
outputBaseDirectory is not set: " + outputPath);
+            }
+            if (path.getNameCount() > 0 && 
"..".equals(path.getName(0).toString())) {
+                throw new IOException(
+                        "Output path must not leave the working directory when 
outputBaseDirectory is not set: "
+                                      + outputPath);
+            }
+            return path;
         }
         Path baseDir = Paths.get(base).toAbsolutePath().normalize();
         // resolve relative paths against the base directory itself, so that 
the path checked here is exactly the path
diff --git 
a/components/camel-ai/camel-docling/src/test/java/org/apache/camel/component/docling/DoclingOutputPathValidationTest.java
 
b/components/camel-ai/camel-docling/src/test/java/org/apache/camel/component/docling/DoclingOutputPathValidationTest.java
index 4bf2ec47cc5b..ea571155978a 100644
--- 
a/components/camel-ai/camel-docling/src/test/java/org/apache/camel/component/docling/DoclingOutputPathValidationTest.java
+++ 
b/components/camel-ai/camel-docling/src/test/java/org/apache/camel/component/docling/DoclingOutputPathValidationTest.java
@@ -47,16 +47,43 @@ class DoclingOutputPathValidationTest extends 
CamelTestSupport {
     // ------------------------------------------------------- no 
outputBaseDirectory
 
     @Test
-    void outputPathWithoutBaseDirectoryIsAllowed() {
-        // no restriction is configured: the header is normalized only and 
passes through, so the run fails later on the
-        // absent docling binary rather than on a containment check
+    void relativeOutputPathWithoutBaseDirectoryIsAllowed() {
+        // a relative header value passes the check, so the run fails later on 
the absent docling binary
         assertThatThrownBy(() -> 
template.requestBodyAndHeader("direct:default", CONTENT,
-                DoclingHeaders.OUTPUT_FILE_PATH, 
tempDir.resolve("out").toString()))
+                DoclingHeaders.OUTPUT_FILE_PATH, "out/sub"))
                 .isInstanceOf(CamelExecutionException.class)
                 .cause()
                 .hasMessageNotContaining("outputBaseDirectory");
     }
 
+    @Test
+    void absoluteOutputPathWithoutBaseDirectoryIsRejected() {
+        assertThatThrownBy(() -> 
template.requestBodyAndHeader("direct:default", CONTENT,
+                DoclingHeaders.OUTPUT_FILE_PATH, 
tempDir.resolve("out").toString()))
+                .isInstanceOf(CamelExecutionException.class)
+                .cause()
+                .isInstanceOf(IOException.class)
+                .hasMessageContaining("must be a relative path when 
outputBaseDirectory is not set");
+    }
+
+    @Test
+    void traversalWithoutBaseDirectoryIsRejected() {
+        // out/../../x normalizes to ../x, which leaves the working directory
+        assertThatThrownBy(() -> 
template.requestBodyAndHeader("direct:default", CONTENT,
+                DoclingHeaders.OUTPUT_FILE_PATH, "out/../../x"))
+                .isInstanceOf(CamelExecutionException.class)
+                .cause()
+                .isInstanceOf(IOException.class)
+                .hasMessageContaining("must not leave the working directory 
when outputBaseDirectory is not set");
+    }
+
+    @Test
+    void absoluteOutputPathWithoutBaseDirectoryIsRejectedInTheBuiltCommand() {
+        assertThatThrownBy(() -> 
buildDoclingCommandFor("/var/www/html/uploads"))
+                .isInstanceOf(IOException.class)
+                .hasMessageContaining("must be a relative path");
+    }
+
     @Test
     void outputPathIsNormalizedInTheBuiltCommand() throws Exception {
         // with outputBaseDirectory unset (the default, and the branch most 
routes hit) the header is still
diff --git 
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index bb4dfcfb3986..f8d410d20a8f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -515,6 +515,17 @@ An `AiToolConfiguration` bean given as the `configuration` 
option no longer repl
   `allowedRoles`. Previously the bean replaced the options of the endpoint and 
the values of the component. The bean
   itself is no longer changed by the options of the endpoints that use it.
 
+=== camel-docling - the CamelDoclingOutputFilePath header is a relative path 
unless outputBaseDirectory is set
+
+When the `outputBaseDirectory` option is not set, the 
`CamelDoclingOutputFilePath` header must now be a relative
+path that does not start with `../` once normalized, the same rule as for the 
custom arguments. An absolute path,
+or a path that leaves the working directory, fails the exchange with an 
`IOException`. Previously the header was
+only normalized and could name any directory.
+
+With `outputBaseDirectory` set, nothing changes: the header must resolve 
inside that directory, and an absolute
+path inside it is accepted. A route that sets an absolute output directory in 
the header sets `outputBaseDirectory`
+to a directory that contains the output directories it uses.
+
 === camel-wordpress - each endpoint uses its own site URL and credentials
 
 Each WordPress endpoint now has a client of its own, set up from the `url`, 
`apiVersion`, `user` and `password`
diff --git 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
index ad7e826a462b..5e744e77f753 100644
--- 
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
+++ 
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/DoclingComponentBuilderFactory.java
@@ -1028,9 +1028,10 @@ public interface DoclingComponentBuilderFactory {
          * When set, the output directory passed to the docling CLI must 
resolve
          * inside this directory once normalized. Applies to the
          * CamelDoclingOutputFilePath header. The check is lexical and does not
-         * resolve symbolic links, matching inputBaseDirectory. When empty, no
-         * directory restriction is applied and the header value is only
-         * normalized.
+         * resolve symbolic links, matching inputBaseDirectory. When empty, the
+         * header value must be a relative path that does not leave the working
+         * directory once normalized; set this option to use absolute output
+         * directories.
          * 
          * The option is a: &lt;code&gt;java.lang.String&lt;/code&gt; type.
          * 
diff --git 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
index c266969a0e6c..3f43d5daad36 100644
--- 
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
+++ 
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/DoclingEndpointBuilderFactory.java
@@ -1347,9 +1347,10 @@ public interface DoclingEndpointBuilderFactory {
          * When set, the output directory passed to the docling CLI must 
resolve
          * inside this directory once normalized. Applies to the
          * CamelDoclingOutputFilePath header. The check is lexical and does not
-         * resolve symbolic links, matching inputBaseDirectory. When empty, no
-         * directory restriction is applied and the header value is only
-         * normalized.
+         * resolve symbolic links, matching inputBaseDirectory. When empty, the
+         * header value must be a relative path that does not leave the working
+         * directory once normalized; set this option to use absolute output
+         * directories.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -2925,9 +2926,10 @@ public interface DoclingEndpointBuilderFactory {
          * When set, the output directory passed to the docling CLI must 
resolve
          * inside this directory once normalized. Applies to the
          * CamelDoclingOutputFilePath header. The check is lexical and does not
-         * resolve symbolic links, matching inputBaseDirectory. When empty, no
-         * directory restriction is applied and the header value is only
-         * normalized.
+         * resolve symbolic links, matching inputBaseDirectory. When empty, the
+         * header value must be a relative path that does not leave the working
+         * directory once normalized; set this option to use absolute output
+         * directories.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 
@@ -4396,9 +4398,10 @@ public interface DoclingEndpointBuilderFactory {
          * When set, the output directory passed to the docling CLI must 
resolve
          * inside this directory once normalized. Applies to the
          * CamelDoclingOutputFilePath header. The check is lexical and does not
-         * resolve symbolic links, matching inputBaseDirectory. When empty, no
-         * directory restriction is applied and the header value is only
-         * normalized.
+         * resolve symbolic links, matching inputBaseDirectory. When empty, the
+         * header value must be a relative path that does not leave the working
+         * directory once normalized; set this option to use absolute output
+         * directories.
          * 
          * The option is a: <code>java.lang.String</code> type.
          * 

Reply via email to