[
https://issues.apache.org/jira/browse/SSHD-730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16370750#comment-16370750
]
Guillaume Nodet commented on SSHD-730:
--------------------------------------
Not sure about using the underlying {{FileSystem}}, but I have at least the
following patch:
{code:java}
diff --git
a/sshd-core/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
b/sshd-core/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
index 7fa19279..f44f7e72 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/util/SelectorUtils.java
@@ -557,9 +557,9 @@ public final class SelectorUtils {
tokens.remove(i);
removedDots++;
} else if (t.equals("..")) {
- tokens.remove(i);
- removedDots++;
if (i >= 1) {
+ tokens.remove(i);
+ removedDots++;
tokens.remove(--i);
removedDots++;
}
diff --git
a/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
b/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
index 51066141..8eb5737c 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/util/SelectorUtilsTest.java
@@ -148,4 +148,10 @@ public class SelectorUtilsTest extends BaseTestSupport {
String actual = SelectorUtils.normalizePath(path, "/");
assertEquals("Mismatched result", "/" + path, actual);
}
+
+ @Test
+ public void testNormalize() {
+ assertEquals("foo/bar",
SelectorUtils.normalizePath("./baz/../foo/./bar", "/"));
+ assertEquals("../foo/bar",
SelectorUtils.normalizePath("../baz/../foo/./bar", "/"));
+ }
}
{code}
> Relative symbolic links with .. is not resolved properly by sftp readLink
> -------------------------------------------------------------------------
>
> Key: SSHD-730
> URL: https://issues.apache.org/jira/browse/SSHD-730
> Project: MINA SSHD
> Issue Type: Bug
> Affects Versions: 1.1.0, 1.2.0, 1.3.0
> Reporter: Lukas Waldmann
> Assignee: Goldstein Lyor
> Priority: Minor
>
> Using sftp to resolve symbolic links doesn't return proper resolution in case
> symbolic link contains ..
> Since version 1.1 the sendLink function of SftpSubsystem uses
> normalizedPath = SelectorUtils.normalizePath(unixPath, "/");
> to normalize path
> This function however return invalid path in case link contains ".."
> So for example if link is "../test/file" than normalizePath returns
> "test/file" which is invalid because in can not be resolved properly in the
> context of the current directory which symbolic link is referring to.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)