Skip to content

Commit e530f11

Browse files
committed
fixup: hide share and mount information from permission string
Signed-off-by: Salvatore Martire <[email protected]>
1 parent 60b6904 commit e530f11

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

apps/dav/lib/Connector/Sabre/AddExtraHeadersPlugin.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99
namespace OCA\DAV\Connector\Sabre;
1010

11+
use OCA\DAV\Connector\PermissionsTrait;
1112
use Psr\Log\LoggerInterface;
1213
use Sabre\DAV\Exception\NotFound;
1314
use Sabre\DAV\Server;
@@ -20,10 +21,14 @@
2021
* to display.
2122
*/
2223
class AddExtraHeadersPlugin extends \Sabre\DAV\ServerPlugin {
24+
25+
use PermissionsTrait;
26+
2327
private ?Server $server = null;
2428

2529
public function __construct(
2630
private LoggerInterface $logger,
31+
private bool $isPublic = false,
2732
) {
2833
}
2934

@@ -57,9 +62,10 @@ private function afterPut(RequestInterface $request, ResponseInterface $response
5762
$response->setHeader('X-NC-OwnerId', $ownerId);
5863
}
5964

60-
$permissions = $node->getDavPermissions();
61-
if ($permissions !== null) {
62-
$response->setHeader('X-NC-Permissions', $permissions);
63-
}
65+
$permissions = $this->getPermissionString(
66+
$this->isPublic,
67+
$node->getDavPermissions()
68+
);
69+
$response->setHeader('X-NC-Permissions', $permissions);
6470
}
6571
}

apps/dav/lib/Connector/Sabre/ServerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public function createServer(
238238
);
239239
}
240240
$server->addPlugin(new CopyEtagHeaderPlugin());
241-
$server->addPlugin(new AddExtraHeadersPlugin($this->logger));
241+
$server->addPlugin(new AddExtraHeadersPlugin($this->logger, $isPublicShare));
242242

243243
// Load dav plugins from apps
244244
$event = new SabrePluginEvent($server);

apps/dav/lib/Server.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ public function __construct(
383383
)
384384
);
385385
}
386-
$this->server->addPlugin(new AddExtraHeadersPlugin($logger));
386+
$this->server->addPlugin(new AddExtraHeadersPlugin($logger, false));
387387
$this->server->addPlugin(new EnablePlugin(
388388
\OCP\Server::get(IConfig::class),
389389
\OCP\Server::get(BirthdayService::class),

apps/dav/tests/unit/Connector/Sabre/AddExtraHeadersPluginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function setUp(): void {
129129
$this->tree = $this->createMock(Tree::class);
130130
$this->server->tree = $this->tree;
131131
$this->logger = $this->createMock(LoggerInterface::class);
132-
$this->plugin = new AddExtraHeadersPlugin($this->logger);
132+
$this->plugin = new AddExtraHeadersPlugin($this->logger, false);
133133
$this->request = $this->createMock(RequestInterface::class);
134134
$this->response = $this->createMock(ResponseInterface::class);
135135
}

0 commit comments

Comments
 (0)