Skip to content

Commit d7b5878

Browse files
committed
open file with special characters in filename
Signed-off-by: sowjanyakch <[email protected]>
1 parent 03757d5 commit d7b5878

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

app/src/main/java/com/nextcloud/talk/filebrowser/webdav/ReadFilesystemOperation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package com.nextcloud.talk.filebrowser.webdav;
88

9+
import android.net.Uri;
910
import android.util.Log;
1011

1112
import com.nextcloud.talk.filebrowser.models.BrowserFile;
@@ -47,7 +48,7 @@ public ReadFilesystemOperation(OkHttpClient okHttpClient, User currentUser, Stri
4748
);
4849
this.okHttpClient = okHttpClientBuilder.build();
4950
this.basePath = currentUser.getBaseUrl() + DavUtils.DAV_PATH + currentUser.getUserId();
50-
this.url = basePath + path;
51+
this.url = basePath + Uri.encode(path, "/");
5152
this.depth = depth;
5253
}
5354

app/src/main/java/com/nextcloud/talk/utils/ApiUtils.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,10 @@ object ApiUtils {
407407

408408
fun getUrlForChunkedUpload(baseUrl: String, user: String): String = "$baseUrl/remote.php/dav/uploads/$user"
409409

410-
fun getUrlForFileDownload(baseUrl: String, user: String, remotePath: String): String =
411-
"$baseUrl/remote.php/dav/files/$user/$remotePath"
410+
fun getUrlForFileDownload(baseUrl: String, user: String, remotePath: String): String {
411+
val encodedRemotePath = Uri.encode(remotePath, "/")
412+
return "$baseUrl/remote.php/dav/files/$user/$encodedRemotePath"
413+
}
412414

413415
fun userFileUploadPath(baseUrl: String, user: String): String = "$baseUrl/remote.php/dav/files/$user"
414416

0 commit comments

Comments
 (0)