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:45:27 UTC
[camel] branch main updated (a7f9e429ee6 -> 83b62ed5e4d)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
from a7f9e429ee6 Add Java snippets on CXF component page, normalize formating markup, re-indent examples
new b61d5b6be4f CAMEL-19421 - Camel-Jira: Use Files.createTempFile in FileConverter instead of creating File directly
new 83b62ed5e4d 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 main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit b61d5b6be4f98b673dc977ad1bc6f004642644ab
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 main
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 83b62ed5e4dd5d6c73a1715783d5124ecc904e41
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 {