Skip to content

Commit

Permalink
Merge pull request #1494 from nextcloud/feature/compatible-file-names
Browse files Browse the repository at this point in the history
Add New Capabilities For Compatible File Names
  • Loading branch information
alperozturk96 authored Aug 23, 2024
2 parents 844ccc2 + 56fb2f1 commit 86b0279
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,12 @@ public class GetCapabilitiesRemoteOperation extends RemoteOperation {
private static final String NODE_SECURITY_GUARD = "security_guard";
private static final String NODE_DIAGNOSTICS = "diagnostics";

// needed for checking compatible filenames
private static final String FORBIDDEN_FILENAME_CHARACTERS = "forbidden_filename_characters";
private static final String FORBIDDEN_FILENAMES = "forbidden_filenames";
private static final String FORBIDDEN_FILENAME_EXTENSIONS = "forbidden_filename_extensions";
private static final String FORBIDDEN_FILENAME_BASE_NAMES = "forbidden_filename_basenames";

private OCCapability currentCapability = null;

public GetCapabilitiesRemoteOperation() {
Expand Down Expand Up @@ -438,6 +444,28 @@ private OCCapability parseResponse(String response) throws JSONException {
capability.setDirectEditingEtag(respDirectEditing.getString("etag"));
}

// region compatible file names
if (respFiles.has(FORBIDDEN_FILENAME_CHARACTERS)) {
JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAME_CHARACTERS);
capability.setForbiddenFilenameCharactersJson(result.toString());
}

if (respFiles.has(FORBIDDEN_FILENAMES)) {
JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAMES);
capability.setForbiddenFilenamesJson(result.toString());
}

if (respFiles.has(FORBIDDEN_FILENAME_EXTENSIONS)) {
JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAME_EXTENSIONS);
capability.setForbiddenFilenameExtensionJson(result.toString());
}

if (respFiles.has(FORBIDDEN_FILENAME_BASE_NAMES)) {
JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAME_BASE_NAMES);
capability.setForbiddenFilenameBaseNamesJson(result.toString());
}
// endregion

Log_OC.d(TAG, "*** Added " + NODE_FILES);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ class OCCapability {
// Security guard
var securityGuard = CapabilityBooleanType.UNKNOWN

// needed for checking compatible filenames
var forbiddenFilenameCharactersJson: String? = null
var forbiddenFilenamesJson: String? = null
var forbiddenFilenameExtensionJson: String? = null
var forbiddenFilenameBaseNamesJson: String? = null

// Etag for capabilities
var etag: String? = ""

Expand Down

0 comments on commit 86b0279

Please sign in to comment.