Skip to content

Commit

Permalink
Merge pull request #763 from nextcloud/backport/761/stable-2.8
Browse files Browse the repository at this point in the history
[stable-2.8] Fix username encoding in file paths
  • Loading branch information
AlvaroBrey authored Nov 25, 2021
2 parents f4a8b46 + 2e8c589 commit 99bcaa3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public String getFilesDavUri(String path) {
}

public Uri getFilesDavUri() {
return Uri.parse(getDavUri() + "/files/" + userId);
return Uri.parse(getDavUri() + "/files/" + getUserId());
}

public Uri getUploadUri() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,18 @@ public ArrayList<RemoteFile> readData(MultiStatus remoteData,

if (isReadFolderOperation) {
we = new WebdavEntry(remoteData.getResponses()[0],
client.getFilesDavUri().getPath());
client.getFilesDavUri().getEncodedPath());
mFolderAndFiles.add(fillOCFile(we));
} else {
start = 0;
}

String stripString = client.getFilesDavUri().getPath();
if (isSearchOperation) {
stripString = stripString.replaceAll(" ", "%20");
}

// loop to update every child
RemoteFile remoteFile;
MultiStatusResponse[] responses = remoteData.getResponses();
for (int i = start; i < responses.length; i++) {
/// new OCFile instance with the data from the server
we = new WebdavEntry(responses[i], stripString);
we = new WebdavEntry(responses[i], client.getFilesDavUri().getEncodedPath());
remoteFile = fillOCFile(we);
mFolderAndFiles.add(remoteFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected RemoteOperationResult run(OwnCloudClient client) {
// Parse response
MultiStatus resp = propfind.getResponseBodyAsMultiStatus();
WebdavEntry we = new WebdavEntry(resp.getResponses()[0],
client.getFilesDavUri().getPath());
client.getFilesDavUri().getEncodedPath());
RemoteFile remoteFile = new RemoteFile(we);
ArrayList<Object> files = new ArrayList<Object>();
files.add(remoteFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ private void readData(MultiStatus remoteData, OwnCloudClient client) {
mFolderAndFiles = new ArrayList<>();

// parse data from remote folder
WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getFilesDavUri().getPath());
WebdavEntry we = new WebdavEntry(remoteData.getResponses()[0], client.getFilesDavUri().getEncodedPath());
mFolderAndFiles.add(fillOCFile(we));

// loop to update every child
RemoteFile remoteFile;
for (int i = 1; i < remoteData.getResponses().length; ++i) {
/// new OCFile instance with the data from the server
we = new WebdavEntry(remoteData.getResponses()[i], client.getFilesDavUri().getPath());
we = new WebdavEntry(remoteData.getResponses()[i], client.getFilesDavUri().getEncodedPath());
remoteFile = fillOCFile(we);
mFolderAndFiles.add(remoteFile);
}
Expand Down

0 comments on commit 99bcaa3

Please sign in to comment.