Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ coverage:
comment:
layout: "header, diff, changes, uncovered, tree"
behavior: default

2 changes: 2 additions & 0 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ pipeline:
services:
server:
image: nextcloudci/server:server-1
server2:
image: nextcloudci/server:server-1

branches: master
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ protected RemoteOperationResult uploadFile(OwnCloudClient client) throws IOExcep
RandomAccessFile raf = null;

File file = new File(mLocalPath);

if (!file.exists()) {
return new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_FILE_NOT_FOUND);
}

SharedPreferences sharedPref = mContext.getApplicationContext().
getSharedPreferences("com.nextcloud.PREFERENCE_upload", Context.MODE_PRIVATE);
String chunkId = String.format("%08d", Math.abs(file.getName().hashCode()));
Expand Down
24 changes: 24 additions & 0 deletions src/com/owncloud/android/lib/resources/files/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

package com.owncloud.android.lib.resources.files;

import com.owncloud.android.lib.common.utils.Log_OC;

import java.io.File;

public class FileUtils {
Expand All @@ -48,4 +50,26 @@ public static boolean isValidName(String fileName) {

return !fileName.contains(PATH_SEPARATOR);
}

/**
* Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | ,
* ? , *
* @param path
* @return
*/
public static boolean isValidPath(String path, boolean versionSupportsForbidenChars) {
boolean result = true;

Log_OC.d(TAG, "path ....... " + path);
if (!versionSupportsForbidenChars &&
(path.contains("\\") || path.contains("<") || path.contains(">") ||
path.contains(":") || path.contains("\"") || path.contains("|") ||
path.contains("?") || path.contains("*") ) ){
result = false;
} else if (path.contains("\\")) {
return false;
}
return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ protected RemoteOperationResult uploadFile(OwnCloudClient client) throws IOExcep

try {
File f = new File(mLocalPath);

if (!f.exists()) {
return new RemoteOperationResult(RemoteOperationResult.ResultCode.LOCAL_FILE_NOT_FOUND);
}

mEntity = new FileRequestEntity(f, mMimeType);
synchronized (mDataTransferListeners) {
((ProgressiveDataTransferer)mEntity)
Expand Down
2 changes: 2 additions & 0 deletions test_client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ dependencies {
androidJacocoAnt "org.jacoco:org.jacoco.core:${project.jacocoVersion}"
androidJacocoAnt "org.jacoco:org.jacoco.report:${project.jacocoVersion}"
androidJacocoAnt "org.jacoco:org.jacoco.agent:${project.jacocoVersion}"
androidTestCompile 'junit:junit:4.12'
implementation 'commons-io:commons-io:2.6'
}

android {
Expand Down
Loading