summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-12-20 15:20:52 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-12-29 17:12:42 +0000
commit541a2a223444bcdcd913ba3e224adbbe5f09f408 (patch)
tree286a6170e9bc165918e4e49fb32c337dea753cd1
parent2528210db26b73b0b079ffe6c653c8960730b93c (diff)
downloadnextcloud-server-541a2a223444bcdcd913ba3e224adbbe5f09f408.tar.gz
nextcloud-server-541a2a223444bcdcd913ba3e224adbbe5f09f408.zip
Handle external share with invalid host
remoteIsOwnCloud might throw an exception when the host is localhost. Handle this case instead of aborting completely. The behavior is the same as that is done 10 lines under it Signed-off-by: Carl Schwan <carl@carlschwan.eu>
-rw-r--r--apps/files_sharing/lib/External/Storage.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/apps/files_sharing/lib/External/Storage.php b/apps/files_sharing/lib/External/Storage.php
index 339770c8601..b4c05c45ad8 100644
--- a/apps/files_sharing/lib/External/Storage.php
+++ b/apps/files_sharing/lib/External/Storage.php
@@ -45,6 +45,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\Storage\IDisableEncryptionStorage;
use OCP\Files\StorageInvalidException;
use OCP\Files\StorageNotAvailableException;
+use OCP\Http\Client\LocalServerException;
class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
/** @var ICloudId */
@@ -315,9 +316,16 @@ class Storage extends DAV implements ISharedStorage, IDisableEncryptionStorage {
$token = $this->getToken();
$password = $this->getPassword();
- // If remote is not an ownCloud do not try to get any share info
- if (!$this->remoteIsOwnCloud()) {
- return ['status' => 'unsupported'];
+ try {
+ // If remote is not an ownCloud do not try to get any share info
+ if (!$this->remoteIsOwnCloud()) {
+ return ['status' => 'unsupported'];
+ }
+ } catch (LocalServerException $e) {
+ // throw this to be on the safe side: the share will still be visible
+ // in the UI in case the failure is intermittent, and the user will
+ // be able to decide whether to remove it if it's really gone
+ throw new StorageNotAvailableException();
}
$url = rtrim($remote, '/') . '/index.php/apps/files_sharing/shareinfo?t=' . $token;