This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new 5f3a26c5 VFS-844: Prevent that source files urlString is twice (#423)
5f3a26c5 is described below
commit 5f3a26c53c7ef7fe44959b71fa05633200f8a58c
Author: beise <[email protected]>
AuthorDate: Sat Sep 16 14:39:12 2023 +0200
VFS-844: Prevent that source files urlString is twice (#423)
URIEncoded.
Prevent that the urlString of a webdav-filename is twice URIEncoded when
file is moved. Results in invalid filename if the filename contains spaces.
Co-authored-by: Thorsten Beise <[email protected]>
---
.../vfs2/provider/webdav4/Webdav4FileObject.java | 3 +--
.../org/apache/commons/vfs2/ProviderRenameTests.java | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git
a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
index ee83f0d5..87e199e9 100644
---
a/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
+++
b/commons-vfs2-jackrabbit2/src/main/java/org/apache/commons/vfs2/provider/webdav4/Webdav4FileObject.java
@@ -38,7 +38,6 @@ import org.apache.commons.vfs2.provider.GenericURLFileName;
import org.apache.commons.vfs2.provider.http4.Http4FileObject;
import org.apache.commons.vfs2.util.FileObjectUtils;
import org.apache.commons.vfs2.util.MonitorOutputStream;
-import org.apache.commons.vfs2.util.URIUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
@@ -423,7 +422,7 @@ public class Webdav4FileObject extends
Http4FileObject<Webdav4FileSystem> {
*/
@Override
protected void doRename(final FileObject newFile) throws Exception {
- final String url =
URIUtils.encodePath(toUrlString((GenericURLFileName) getName()));
+ final String url = toUrlString((GenericURLFileName) getName());
final String dest = toUrlString((GenericURLFileName)
newFile.getName(), false);
final HttpMove request = new HttpMove(url, dest, false);
setupRequest(request);
diff --git
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/ProviderRenameTests.java
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/ProviderRenameTests.java
index d8c466b6..c59415fb 100644
---
a/commons-vfs2/src/test/java/org/apache/commons/vfs2/ProviderRenameTests.java
+++
b/commons-vfs2/src/test/java/org/apache/commons/vfs2/ProviderRenameTests.java
@@ -96,6 +96,23 @@ public class ProviderRenameTests extends
AbstractProviderTestCase {
moveFile(scratchFolder, file, content);
}
+ /**
+ * Tests create-delete-create-a-file sequence on the same file system.
+ */
+ @Test
+ public void testRenameFileWithSpaces() throws Exception {
+ final FileObject scratchFolder = createScratchFolder();
+
+ // Create direct child of the test folder
+ final FileObject file = scratchFolder.resolveFile("file space.txt");
+ assertFalse(file.exists());
+
+ final String content = createTestFile(file);
+
+ // Make sure we can move the new file to another file on the same file
system
+ moveFile(scratchFolder, file, content);
+ }
+
/**
* Moves a file from a child folder to a parent folder to test what
happens when the original folder is now empty.
*