This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch camel-2.23.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit dc06d1b10577d9a536d16f36bb3845e3b34c1f20 Author: cblamauer <52042437+cblama...@users.noreply.github.com> AuthorDate: Thu Jun 20 17:19:18 2019 +0200 CAMEL-13667 Windows network UNC paths not treated correctly (File2/tempPrefix) --- camel-core/src/main/java/org/apache/camel/util/FileUtil.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java index 632ab0b..f9c7d9e 100644 --- a/camel-core/src/main/java/org/apache/camel/util/FileUtil.java +++ b/camel-core/src/main/java/org/apache/camel/util/FileUtil.java @@ -300,7 +300,14 @@ public final class FileUtil { boolean endsWithSlash = path.endsWith("/") || path.endsWith("\\"); // preserve starting slash if given in input path - boolean startsWithSlash = path.startsWith("/") || path.startsWith("\\"); + int cntSlashsAtStart = 0; + if (path.startsWith("/") || path.startsWith("\\")) { + cntSlashsAtStart++; + // for Windows, preserve up to 2 starting slashes, which is necessary for UNC paths. + if (isWindows() && path.length() > 1 && (path.charAt(1) == '/' || path.charAt(1) == '\\')) { + cntSlashsAtStart++; + } + } Deque<String> stack = new ArrayDeque<>(); @@ -321,7 +328,7 @@ public final class FileUtil { // build path based on stack StringBuilder sb = new StringBuilder(); - if (startsWithSlash) { + for (int i = 0; i < cntSlashsAtStart; i++) { sb.append(separator); }