Skip to content
Merged
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
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
use OCP\Lock\LockedException;
use OCP\Mail\IMailer;
use OCP\Server;
use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\Exceptions\ShareTokenException;
use OCP\Share\IManager;
Expand Down Expand Up @@ -800,6 +801,9 @@ public function createShare(
} catch (HintException $e) {
$code = $e->getCode() === 0 ? 403 : $e->getCode();
throw new OCSException($e->getHint(), $code);
} catch (GenericShareException|\InvalidArgumentException $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException($e->getMessage(), $e);
} catch (\Exception $e) {
$this->logger->error($e->getMessage(), ['exception' => $e]);
throw new OCSForbiddenException('Failed to create share.', $e);
Expand Down
6 changes: 4 additions & 2 deletions apps/files_sharing/src/mixins/ShareRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
// TODO: remove when ie not supported
import 'url-search-params-polyfill'

import { emit } from '@nextcloud/event-bus'
import { showError } from '@nextcloud/dialogs'
import { generateOcsUrl } from '@nextcloud/router'
import axios from '@nextcloud/axios'

import Share from '../models/Share.ts'
import { emit } from '@nextcloud/event-bus'

const shareUrl = generateOcsUrl('apps/files_sharing/api/v1/shares')

Expand Down Expand Up @@ -45,7 +47,7 @@ export default {
} catch (error) {
console.error('Error while creating share', error)
const errorMessage = error?.response?.data?.ocs?.meta?.message
OC.Notification.showTemporary(
showError(
errorMessage ? t('files_sharing', 'Error creating the share: {errorMessage}', { errorMessage }) : t('files_sharing', 'Error creating the share'),
{ type: 'error' },
)
Expand Down
14 changes: 12 additions & 2 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
</NcButton>
<NcButton type="primary"
data-cy-files-sharing-share-editor-action="save"
:disabled="creating"
@click="saveShare">
{{ shareButtonText }}
<template v-if="creating" #icon>
Expand Down Expand Up @@ -1003,8 +1004,16 @@ export default {
incomingShare.password = this.share.password
}

this.creating = true
const share = await this.addShare(incomingShare)
let share
try {
this.creating = true
share = await this.addShare(incomingShare)
} catch (error) {
this.creating = false
// Error is already handled by ShareRequests mixin
return
}

// ugly hack to make code work - we need the id to be set but at the same time we need to keep values we want to update
this.share._share.id = share.id
await this.queueUpdate(...permissionsAndAttributes)
Expand All @@ -1018,6 +1027,7 @@ export default {
}
}
}

this.share = share
this.creating = false
this.$emit('add:share', this.share)
Expand Down
2 changes: 0 additions & 2 deletions dist/4542-4542.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/4542-4542.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/4542-4542.js.map.license

This file was deleted.

2 changes: 2 additions & 0 deletions dist/4672-4672.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/4672-4672.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/4672-4672.js.map.license
4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,11 @@ protected function pathCreateChecks($path) {
$mounts = $this->mountManager->findIn($path->getPath());
foreach ($mounts as $mount) {
if ($mount->getStorage()->instanceOfStorage('\OCA\Files_Sharing\ISharedStorage')) {
throw new \InvalidArgumentException($this->l->t('Path contains files shared with you'));
// Using a flat sharing model ensures the file owner can always see who has access.
// Allowing parent folder sharing would require tracking inherited access, which adds complexity
// and hurts performance/scalability.
// So we forbid sharing a parent folder of a share you received.
throw new \InvalidArgumentException($this->l->t('You cannot share a folder that contains other shares'));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,7 @@ public function testLinkCreateChecksReadOnly(): void {

public function testPathCreateChecksContainsSharedMount(): void {
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Path contains files shared with you');
$this->expectExceptionMessage('You cannot share a folder that contains other shares');

$path = $this->createMock(Folder::class);
$path->method('getPath')->willReturn('path');
Expand Down
Loading