You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/06/06 15:49:26 UTC

[camel] branch camel-3.14.x updated (4b3d41e69f2 -> 865bdecfe60)

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

acosentino pushed a change to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 4b3d41e69f2 Regen for commit 14826e02c72d2bddf2838177ebf73ad829f6ec8e
     new fa3543ab08f CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly
     new 865bdecfe60 Update components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/camel/component/jira/FileConverter.java | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)


[camel] 01/02: CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit fa3543ab08f6fba7804832fb3d0cdfc7fdd4e394
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jun 6 17:06:33 2023 +0200

    CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../org/apache/camel/component/jira/FileConverter.java | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
index d7d2f3642d7..e19d85e4ef9 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.jira;
 import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
+import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 
 import org.apache.camel.Converter;
@@ -34,20 +35,13 @@ public final class FileConverter {
     @Converter
     public static File genericToFile(GenericFile<File> genericFile, Exchange exchange) throws IOException {
         Object body = genericFile.getBody();
-        File file;
+        File file = null;
+        Path path;
         if (body instanceof byte[]) {
             byte[] bos = (byte[]) body;
-            String destDir = System.getProperty("java.io.tmpdir");
-            if (destDir != null && !destDir.endsWith(File.separator)) {
-                destDir += File.separator;
-            }
-            file = new File(destDir, genericFile.getFileName());
-            if (!file.getCanonicalPath().startsWith(destDir)) {
-                throw new IOException("File is not jailed to the destination directory");
-            }
-            Files.write(file.toPath(), bos, StandardOpenOption.CREATE);
-            // delete the temporary file on exit, as other routing may need the file for post processing
-            file.deleteOnExit();
+            path = Files.createTempFile(genericFile.getFileName(), null, null);
+            Files.write(path, bos, StandardOpenOption.CREATE);
+            path.toFile().deleteOnExit();
         } else {
             file = (File) body;
         }


[camel] 02/02: Update components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch camel-3.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 865bdecfe602d81150a7a57474d71e721f4fb0ff
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Jun 6 17:16:09 2023 +0200

    Update components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
    
    Co-authored-by: Jonathan Leitschuh <jo...@gmail.com>
---
 .../src/main/java/org/apache/camel/component/jira/FileConverter.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
index e19d85e4ef9..f3d838aedea 100644
--- a/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
+++ b/components/camel-jira/src/main/java/org/apache/camel/component/jira/FileConverter.java
@@ -39,7 +39,7 @@ public final class FileConverter {
         Path path;
         if (body instanceof byte[]) {
             byte[] bos = (byte[]) body;
-            path = Files.createTempFile(genericFile.getFileName(), null, null);
+            path = Files.createTempFile(genericFile.getFileName(), null);
             Files.write(path, bos, StandardOpenOption.CREATE);
             path.toFile().deleteOnExit();
         } else {