From 58e19244a91877e20fa2684ff6fcd1a9631d580c Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 3 Jul 2024 10:35:42 +0200 Subject: [PATCH 1/8] Add new capabilities Signed-off-by: alperozturk --- .../GetCapabilitiesRemoteOperation.java | 25 +++++++++++++++++++ .../lib/resources/status/OCCapability.kt | 5 ++++ 2 files changed, 30 insertions(+) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index 70f084145..a0189e5dd 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -160,6 +160,11 @@ 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 OCCapability currentCapability = null; public GetCapabilitiesRemoteOperation() { @@ -438,6 +443,26 @@ private OCCapability parseResponse(String response) throws JSONException { capability.setDirectEditingEtag(respDirectEditing.getString("etag")); } + // region compatible file names + if (respCapabilities.has(FORBIDDEN_FILENAME_CHARACTERS)) { + boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAME_CHARACTERS); + CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); + capability.setForbiddenFilenameCharacters(result); + } + + if (respCapabilities.has(FORBIDDEN_FILENAMES)) { + boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAMES); + CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); + capability.setForbiddenFilenames(result); + } + + if (respCapabilities.has(FORBIDDEN_FILENAME_EXTENSIONS)) { + boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAME_EXTENSIONS); + CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); + capability.setForbiddenFilenameExtension(result); + } + // endregion + Log_OC.d(TAG, "*** Added " + NODE_FILES); } diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index c990fb61a..0e3db4eb8 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -104,6 +104,11 @@ class OCCapability { // Security guard var securityGuard = CapabilityBooleanType.UNKNOWN + // needed for checking compatible filenames + var forbiddenFilenameCharacters = CapabilityBooleanType.UNKNOWN + var forbiddenFilenames = CapabilityBooleanType.UNKNOWN + var forbiddenFilenameExtension = CapabilityBooleanType.UNKNOWN + // Etag for capabilities var etag: String? = "" From 993bce7a075e4cc0a8dc9619670d030b90bfa2ee Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 3 Jul 2024 12:00:38 +0200 Subject: [PATCH 2/8] Use correct node Signed-off-by: alperozturk --- .../resources/status/GetCapabilitiesRemoteOperation.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index a0189e5dd..7f748d166 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -444,19 +444,19 @@ private OCCapability parseResponse(String response) throws JSONException { } // region compatible file names - if (respCapabilities.has(FORBIDDEN_FILENAME_CHARACTERS)) { + if (respFiles.has(FORBIDDEN_FILENAME_CHARACTERS)) { boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAME_CHARACTERS); CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); capability.setForbiddenFilenameCharacters(result); } - if (respCapabilities.has(FORBIDDEN_FILENAMES)) { + if (respFiles.has(FORBIDDEN_FILENAMES)) { boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAMES); CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); capability.setForbiddenFilenames(result); } - if (respCapabilities.has(FORBIDDEN_FILENAME_EXTENSIONS)) { + if (respFiles.has(FORBIDDEN_FILENAME_EXTENSIONS)) { boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAME_EXTENSIONS); CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); capability.setForbiddenFilenameExtension(result); From a9357e42c18e08729af2d59bc39f4b469ecaa27f Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 3 Jul 2024 12:36:36 +0200 Subject: [PATCH 3/8] Add new capabilities Signed-off-by: alperozturk --- .../status/GetCapabilitiesRemoteOperation.java | 13 ++++++++++--- .../android/lib/resources/status/OCCapability.kt | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index 7f748d166..7b4a18781 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -28,6 +28,8 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; /** * Get the Capabilities from the server @@ -445,9 +447,14 @@ private OCCapability parseResponse(String response) throws JSONException { // region compatible file names if (respFiles.has(FORBIDDEN_FILENAME_CHARACTERS)) { - boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAME_CHARACTERS); - CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); - capability.setForbiddenFilenameCharacters(result); + JSONArray forbiddenCharactersArray = respFiles.getJSONArray(FORBIDDEN_FILENAME_CHARACTERS); + Set forbiddenCharacterList = new HashSet<>(); + for (int i = 0; i < forbiddenCharactersArray.length(); i++) { + String element = forbiddenCharactersArray.getString(i); + forbiddenCharacterList.add(element); + } + capability.setForbiddenFilenameCharacterList(forbiddenCharacterList); + capability.setForbiddenFilenameCharacters(CapabilityBooleanType.TRUE); } if (respFiles.has(FORBIDDEN_FILENAMES)) { diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index 0e3db4eb8..41769316a 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -108,6 +108,7 @@ class OCCapability { var forbiddenFilenameCharacters = CapabilityBooleanType.UNKNOWN var forbiddenFilenames = CapabilityBooleanType.UNKNOWN var forbiddenFilenameExtension = CapabilityBooleanType.UNKNOWN + var forbiddenFilenameCharacterList: MutableSet = mutableSetOf() // Etag for capabilities var etag: String? = "" From da7e9b1bd8356e1be07945666f1ecf2238fd1715 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 3 Jul 2024 14:42:39 +0200 Subject: [PATCH 4/8] remove backend forbidden char list Signed-off-by: alperozturk --- .../resources/status/GetCapabilitiesRemoteOperation.java | 9 --------- .../android/lib/resources/status/OCCapability.kt | 1 - 2 files changed, 10 deletions(-) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index 7b4a18781..7a0dc8db0 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -28,8 +28,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; -import java.util.Set; /** * Get the Capabilities from the server @@ -447,13 +445,6 @@ private OCCapability parseResponse(String response) throws JSONException { // region compatible file names if (respFiles.has(FORBIDDEN_FILENAME_CHARACTERS)) { - JSONArray forbiddenCharactersArray = respFiles.getJSONArray(FORBIDDEN_FILENAME_CHARACTERS); - Set forbiddenCharacterList = new HashSet<>(); - for (int i = 0; i < forbiddenCharactersArray.length(); i++) { - String element = forbiddenCharactersArray.getString(i); - forbiddenCharacterList.add(element); - } - capability.setForbiddenFilenameCharacterList(forbiddenCharacterList); capability.setForbiddenFilenameCharacters(CapabilityBooleanType.TRUE); } diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index 41769316a..0e3db4eb8 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -108,7 +108,6 @@ class OCCapability { var forbiddenFilenameCharacters = CapabilityBooleanType.UNKNOWN var forbiddenFilenames = CapabilityBooleanType.UNKNOWN var forbiddenFilenameExtension = CapabilityBooleanType.UNKNOWN - var forbiddenFilenameCharacterList: MutableSet = mutableSetOf() // Etag for capabilities var etag: String? = "" From 7968e35c817461f283dd34ee89266d48dc70ebf0 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 17 Jul 2024 15:18:52 +0200 Subject: [PATCH 5/8] Fix json parse Signed-off-by: alperozturk --- .../resources/status/GetCapabilitiesRemoteOperation.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index 7a0dc8db0..b4c730502 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -449,14 +449,14 @@ private OCCapability parseResponse(String response) throws JSONException { } if (respFiles.has(FORBIDDEN_FILENAMES)) { - boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAMES); - CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); + JSONArray forbiddenFilenames = respFiles.getJSONArray(FORBIDDEN_FILENAMES); + CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(forbiddenFilenames.length() > 0); capability.setForbiddenFilenames(result); } if (respFiles.has(FORBIDDEN_FILENAME_EXTENSIONS)) { - boolean capabilityValue = respFiles.getBoolean(FORBIDDEN_FILENAME_EXTENSIONS); - CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(capabilityValue); + JSONArray forbiddenFilenamesExtensions = respFiles.getJSONArray(FORBIDDEN_FILENAME_EXTENSIONS); + CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(forbiddenFilenamesExtensions.length() > 0); capability.setForbiddenFilenameExtension(result); } // endregion From 6a41a52b59eb1bd4ab7b656836f8342a6ddb11fd Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 17 Jul 2024 16:50:26 +0200 Subject: [PATCH 6/8] Use backend response for validation Signed-off-by: alperozturk --- .../status/GetCapabilitiesRemoteOperation.java | 13 ++++++------- .../android/lib/resources/status/OCCapability.kt | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index b4c730502..4e071925d 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -445,19 +445,18 @@ private OCCapability parseResponse(String response) throws JSONException { // region compatible file names if (respFiles.has(FORBIDDEN_FILENAME_CHARACTERS)) { - capability.setForbiddenFilenameCharacters(CapabilityBooleanType.TRUE); + JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAME_CHARACTERS); + capability.setForbiddenFilenameCharactersJson(result.toString()); } if (respFiles.has(FORBIDDEN_FILENAMES)) { - JSONArray forbiddenFilenames = respFiles.getJSONArray(FORBIDDEN_FILENAMES); - CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(forbiddenFilenames.length() > 0); - capability.setForbiddenFilenames(result); + JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAMES); + capability.setForbiddenFilenamesJson(result.toString()); } if (respFiles.has(FORBIDDEN_FILENAME_EXTENSIONS)) { - JSONArray forbiddenFilenamesExtensions = respFiles.getJSONArray(FORBIDDEN_FILENAME_EXTENSIONS); - CapabilityBooleanType result = CapabilityBooleanType.fromBooleanValue(forbiddenFilenamesExtensions.length() > 0); - capability.setForbiddenFilenameExtension(result); + JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAME_EXTENSIONS); + capability.setForbiddenFilenameExtensionJson(result.toString()); } // endregion diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index 0e3db4eb8..e4aaf226d 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -105,9 +105,9 @@ class OCCapability { var securityGuard = CapabilityBooleanType.UNKNOWN // needed for checking compatible filenames - var forbiddenFilenameCharacters = CapabilityBooleanType.UNKNOWN - var forbiddenFilenames = CapabilityBooleanType.UNKNOWN - var forbiddenFilenameExtension = CapabilityBooleanType.UNKNOWN + var forbiddenFilenameCharactersJson: String? = null + var forbiddenFilenamesJson: String? = null + var forbiddenFilenameExtensionJson: String? = null // Etag for capabilities var etag: String? = "" From 88f64a52340e9d035086ffa324c6d4308b5a8216 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 19 Jul 2024 09:25:22 +0200 Subject: [PATCH 7/8] Add base names Signed-off-by: alperozturk --- .../resources/status/GetCapabilitiesRemoteOperation.java | 6 ++++++ .../owncloud/android/lib/resources/status/OCCapability.kt | 1 + 2 files changed, 7 insertions(+) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index 4e071925d..30975b317 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -164,6 +164,7 @@ public class GetCapabilitiesRemoteOperation extends RemoteOperation { 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; @@ -458,6 +459,11 @@ private OCCapability parseResponse(String response) throws JSONException { 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.setForbiddenFilenameBaseNames(result.toString()); + } // endregion Log_OC.d(TAG, "*** Added " + NODE_FILES); diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index e4aaf226d..d2da90bea 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -108,6 +108,7 @@ class OCCapability { var forbiddenFilenameCharactersJson: String? = null var forbiddenFilenamesJson: String? = null var forbiddenFilenameExtensionJson: String? = null + var forbiddenFilenameBaseNames: String? = null // Etag for capabilities var etag: String? = "" From 56fb2f1ee98fe0c4f1ccae0219965ef0313748b0 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 22 Jul 2024 11:29:29 +0200 Subject: [PATCH 8/8] Update name Signed-off-by: alperozturk --- .../lib/resources/status/GetCapabilitiesRemoteOperation.java | 2 +- .../com/owncloud/android/lib/resources/status/OCCapability.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java index 30975b317..acd225b18 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/GetCapabilitiesRemoteOperation.java @@ -462,7 +462,7 @@ private OCCapability parseResponse(String response) throws JSONException { if (respFiles.has(FORBIDDEN_FILENAME_BASE_NAMES)) { JSONArray result = respFiles.getJSONArray(FORBIDDEN_FILENAME_BASE_NAMES); - capability.setForbiddenFilenameBaseNames(result.toString()); + capability.setForbiddenFilenameBaseNamesJson(result.toString()); } // endregion diff --git a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt index d2da90bea..e6bdf3903 100644 --- a/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt +++ b/library/src/main/java/com/owncloud/android/lib/resources/status/OCCapability.kt @@ -108,7 +108,7 @@ class OCCapability { var forbiddenFilenameCharactersJson: String? = null var forbiddenFilenamesJson: String? = null var forbiddenFilenameExtensionJson: String? = null - var forbiddenFilenameBaseNames: String? = null + var forbiddenFilenameBaseNamesJson: String? = null // Etag for capabilities var etag: String? = ""