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 2019/06/21 12:29:27 UTC

[camel] branch master updated (5b112ee -> cd8ddf4)

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

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


    from 5b112ee  Regen again. I love regen.
     new d3b7836  CAMEL-13667
     new cd8ddf4  CAMEL-13667

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:
 .../src/test/java/org/apache/camel/util/FileUtilTest.java     |  4 ++++
 .../src/main/java/org/apache/camel/util/FileUtil.java         | 11 +++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)


[camel] 02/02: CAMEL-13667

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

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

commit cd8ddf44572c33254ff0a272e30a370d3b00d129
Author: cblamauer <52...@users.noreply.github.com>
AuthorDate: Thu Jun 20 17:43:14 2019 +0200

    CAMEL-13667
    
    Windows network UNC paths not treated correctly (File2/tempPrefix) test
---
 core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java b/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
index 2c2388a..089c235 100644
--- a/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
@@ -168,6 +168,8 @@ public class FileUtilTest extends Assert {
             assertEquals("foo\\bar\\baz", FileUtil.compactPath("foo\\bar\\.\\baz"));
             assertEquals("foo\\bar\\baz", FileUtil.compactPath("foo\\bar\\\\baz"));
             assertEquals("\\foo\\bar\\baz", FileUtil.compactPath("\\foo\\bar\\baz"));
+            // Test that multiple back-slashes at the beginning are preserved, this is necessary for network UNC paths.
+            assertEquals("\\\\foo\\bar\\baz", FileUtil.compactPath("\\\\foo\\bar\\baz"));
             assertEquals("\\", FileUtil.compactPath("\\"));
             assertEquals("\\", FileUtil.compactPath("/"));
             assertEquals("/", FileUtil.compactPath("\\", '/'));
@@ -187,6 +189,8 @@ public class FileUtilTest extends Assert {
             assertEquals("foo/bar/baz", FileUtil.compactPath("foo/bar/./baz"));
             assertEquals("foo/bar/baz", FileUtil.compactPath("foo/bar//baz"));
             assertEquals("/foo/bar/baz", FileUtil.compactPath("/foo/bar/baz"));
+            // Do not preserve multiple slashes at the beginning if not on Windows.
+            assertEquals("/foo/bar/baz", FileUtil.compactPath("//foo/bar/baz"));
             assertEquals("/", FileUtil.compactPath("/"));
             assertEquals("/", FileUtil.compactPath("\\"));
             assertEquals("/", FileUtil.compactPath("/", '/'));


[camel] 01/02: CAMEL-13667

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

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

commit d3b78367c482764155a847d014f8760afbd9421d
Author: cblamauer <52...@users.noreply.github.com>
AuthorDate: Thu Jun 20 17:13:19 2019 +0200

    CAMEL-13667
    
    Windows network UNC paths not treated correctly (File2/tempPrefix)
---
 .../src/main/java/org/apache/camel/util/FileUtil.java         | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
index 852e540..1bb3015 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/FileUtil.java
@@ -292,7 +292,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<>();
 
@@ -313,7 +320,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);
         }