From dcd28ab84532bc38c609f744df5fe5f7c0c6ab21 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Thu, 18 Jan 2024 10:48:11 +0000 Subject: [PATCH 1/4] Formatted url --- .../GetRemoteAppRegistryOperation.kt | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt index e8ea864a587..4203d1f1602 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt @@ -43,10 +43,9 @@ class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperati var result: RemoteOperationResult try { - val uriBuilder = client.baseUri.buildUpon().apply { - appendEncodedPath(appUrl) - } - val getMethod = GetMethod(URL(uriBuilder.build().toString())) + val urlFormatted = removeSubfolder(client.baseUri.toString()) + appUrl + val getMethod = GetMethod(URL(urlFormatted)) + val status = client.executeHttpMethod(getMethod) val response = getMethod.getResponseBodyAsString() @@ -75,4 +74,19 @@ class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperati return result } + + private fun removeSubfolder(url: String): String { + val doubleSlashIndex = url.indexOf("//") + return if (doubleSlashIndex >= 0) { + val nextSlashIndex = url.indexOf('/', doubleSlashIndex + 2) + if (nextSlashIndex >= 0) { + val result = url.substring(0, nextSlashIndex) + return if (result.endsWith("/")) result else "$result/" + } else { + if (url.endsWith("/")) url else "$url/" + } + } else { + if (url.endsWith("/")) url else "$url/" + } + } } From c16521c18e04a8da8f011f96cce5c7442fecdf4c Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Mon, 22 Jan 2024 08:29:09 +0000 Subject: [PATCH 2/4] Changed algorithm --- .../appregistry/GetRemoteAppRegistryOperation.kt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt index 4203d1f1602..5168c216ca5 100644 --- a/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt +++ b/owncloudComLibrary/src/main/java/com/owncloud/android/lib/resources/appregistry/GetRemoteAppRegistryOperation.kt @@ -77,14 +77,10 @@ class GetRemoteAppRegistryOperation(private val appUrl: String?) : RemoteOperati private fun removeSubfolder(url: String): String { val doubleSlashIndex = url.indexOf("//") - return if (doubleSlashIndex >= 0) { - val nextSlashIndex = url.indexOf('/', doubleSlashIndex + 2) - if (nextSlashIndex >= 0) { - val result = url.substring(0, nextSlashIndex) - return if (result.endsWith("/")) result else "$result/" - } else { - if (url.endsWith("/")) url else "$url/" - } + val nextSlashIndex = url.indexOf('/', doubleSlashIndex + 2) + return if (nextSlashIndex >= 0) { + val result = url.substring(0, nextSlashIndex) + if (result.endsWith("/")) result else "$result/" } else { if (url.endsWith("/")) url else "$url/" } From 0d7dbf8f16f7f0006b8f2ef57bfcacb266d8e078 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Mon, 22 Jan 2024 08:34:22 +0000 Subject: [PATCH 3/4] Added calens --- changelog/unreleased/4287 | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 changelog/unreleased/4287 diff --git a/changelog/unreleased/4287 b/changelog/unreleased/4287 new file mode 100644 index 00000000000..3864427a7c6 --- /dev/null +++ b/changelog/unreleased/4287 @@ -0,0 +1,7 @@ +Bugfix: Fix in the handling of the base URL + +Base URL has been formatted in GetRemoteAppRegistryOperation +when server instance is installed in subfolder, so that the endpoint is formed correctly. + +https://github.com/owncloud/android/issues/4279 +https://github.com/owncloud/android/pull/4287 From 522d9bb0edae47a6715f780d159190fd1238fda3 Mon Sep 17 00:00:00 2001 From: Aitorbp Date: Mon, 22 Jan 2024 08:35:05 +0000 Subject: [PATCH 4/4] Calens changelog updated --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cc88499342..cfb1a72ce7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ ownCloud admins and users. * Bugfix - Bugs related to Details view: [#4188](https://github.com/owncloud/android/issues/4188) * Bugfix - Some Null Pointer Exceptions fixed from Google Play: [#4207](https://github.com/owncloud/android/issues/4207) * Bugfix - Add "scope" parameter to /token endpoint HTTP requests: [#4260](https://github.com/owncloud/android/pull/4260) +* Bugfix - Fix in the handling of the base URL: [#4279](https://github.com/owncloud/android/issues/4279) * Change - Android library as a module instead of submodule: [#3962](https://github.com/owncloud/android/issues/3962) * Enhancement - Koin DSL: [#3966](https://github.com/owncloud/android/pull/3966) * Enhancement - Unit tests for datasources classes - Part 1 & Fixes: [#4063](https://github.com/owncloud/android/issues/4063) @@ -103,6 +104,14 @@ ownCloud admins and users. https://github.com/owncloud/android/pull/4260 +* Bugfix - Fix in the handling of the base URL: [#4279](https://github.com/owncloud/android/issues/4279) + + Base URL has been formatted in GetRemoteAppRegistryOperation when server + instance is installed in subfolder, so that the endpoint is formed correctly. + + https://github.com/owncloud/android/issues/4279 + https://github.com/owncloud/android/pull/4287 + * Change - Android library as a module instead of submodule: [#3962](https://github.com/owncloud/android/issues/3962) Android library, containing all networking stuff, is now the 5th module in the