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:48:48 UTC

[camel] branch camel-2.23.x updated (d30c23e -> c46cae7)

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

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


    from d30c23e  Fixing failing scala tests
     new dc06d1b  CAMEL-13667
     new c46cae7  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:
 camel-core/src/main/java/org/apache/camel/util/FileUtil.java  | 11 +++++++++--
 .../src/test/java/org/apache/camel/util/FileUtilTest.java     |  4 ++++
 2 files changed, 13 insertions(+), 2 deletions(-)


[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 camel-2.23.x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit dc06d1b10577d9a536d16f36bb3845e3b34c1f20
Author: cblamauer <52...@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);
         }
 


[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 camel-2.23.x
in repository https://gitbox.apache.org/repos/asf/camel.git

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

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

diff --git a/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java b/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
index 59a2e82..4b024e3 100644
--- a/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
+++ b/camel-core/src/test/java/org/apache/camel/util/FileUtilTest.java
@@ -171,6 +171,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("\\", '/'));
@@ -190,6 +192,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("/", '/'));