diff options
author | chrismair <chrismair@531de8e6-9941-0410-b38b-9a92acbe0330> | 2009-06-14 00:31:02 +0000 |
---|---|---|
committer | chrismair <chrismair@531de8e6-9941-0410-b38b-9a92acbe0330> | 2009-06-14 00:31:02 +0000 |
commit | 4d0d55e11a0ddffbf24437c7e62511b0a34d196b (patch) | |
tree | ade2afe345c510c1ee973256ea0f8082031a3751 | |
parent | 899f9bd64499ce2a3f8492399e4910f27a8e1e4a (diff) | |
download | mockftpserver-4d0d55e11a0ddffbf24437c7e62511b0a34d196b.tar.gz |
Fix Bug #2797980: “UnixFakeFileSystem IsValidName Regex incorrect”
git-svn-id: svn://svn.code.sf.net/p/mockftpserver/code@233 531de8e6-9941-0410-b38b-9a92acbe0330
2 files changed, 6 insertions, 3 deletions
diff --git a/MockFtpServer/src/main/java/org/mockftpserver/fake/filesystem/UnixFakeFileSystem.java b/MockFtpServer/src/main/java/org/mockftpserver/fake/filesystem/UnixFakeFileSystem.java index 0a19184..3d4b579 100644 --- a/MockFtpServer/src/main/java/org/mockftpserver/fake/filesystem/UnixFakeFileSystem.java +++ b/MockFtpServer/src/main/java/org/mockftpserver/fake/filesystem/UnixFakeFileSystem.java @@ -52,8 +52,9 @@ public class UnixFakeFileSystem extends AbstractFakeFileSystem { /**
* Return true if the specified path designates a valid (absolute) file path. For Unix,
- * a path is valid if it starts with the '/' character, followed by an optional sequence of
- * any characters except '/'.
+ * a path is valid if it starts with the '/' character, followed by zero or more names
+ * (a sequence of any characters except '/'), delimited by '/'. The path may optionally
+ * contain a terminating '/'.
*
* @param path - the path
* @return true if path is valid, false otherwise
@@ -62,7 +63,8 @@ public class UnixFakeFileSystem extends AbstractFakeFileSystem { protected boolean isValidName(String path) {
Assert.notNull(path, "path");
// Any character but '/'
- return path.matches("\\/|(\\/[^\\/]+)+");
+ return path.matches("\\/|(\\/[^\\/]+\\/?)+");
+
}
/**
diff --git a/MockFtpServer/src/test/groovy/org/mockftpserver/fake/filesystem/UnixFakeFileSystemTest.groovy b/MockFtpServer/src/test/groovy/org/mockftpserver/fake/filesystem/UnixFakeFileSystemTest.groovy index d929817..ff01b68 100644 --- a/MockFtpServer/src/test/groovy/org/mockftpserver/fake/filesystem/UnixFakeFileSystemTest.groovy +++ b/MockFtpServer/src/test/groovy/org/mockftpserver/fake/filesystem/UnixFakeFileSystemTest.groovy @@ -92,6 +92,7 @@ class UnixFakeFileSystemTest extends AbstractFakeFileSystemTest { void testIsValidName() { ["/abc", + "/test/", "/ABC/def", "/abc/d!ef", "/abc/DEF/h(ij)!@#\$%^&*()-_+=~`,.<>?;:[]{}\\|abc", |