Skip to content

Commit cd28335

Browse files
committed
fix: check admin before file read
Signed-off-by: Elizabeth Danzberger <elizabeth@elzody.dev>
1 parent 954d048 commit cd28335

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lib/Controller/WopiController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,13 @@ public function uploadSettingsFile(string $fileId, string $access_token): JSONRe
448448
throw new \Exception('UserID is empty');
449449
}
450450

451+
$isUserAdmin = $this->groupManager->isAdmin($userId);
452+
// Use the fileId as a file path URL (e.g., "/settings/systemconfig/wordbook/en_US%20(1).dic")
453+
$settingsUrl = new SettingsUrl($fileId);
454+
if ($settingsUrl->isSystemConfig() && !$isUserAdmin) {
455+
throw new NotPermittedException();
456+
}
457+
451458
$content = fopen('php://input', 'rb');
452459
if (!$content) {
453460
throw new \Exception('Failed to read input stream.');
@@ -456,12 +463,6 @@ public function uploadSettingsFile(string $fileId, string $access_token): JSONRe
456463
$fileContent = stream_get_contents($content);
457464
fclose($content);
458465

459-
$isUserAdmin = $this->groupManager->isAdmin($userId);
460-
// Use the fileId as a file path URL (e.g., "/settings/systemconfig/wordbook/en_US%20(1).dic")
461-
$settingsUrl = new SettingsUrl($fileId);
462-
if ($settingsUrl->isSystemConfig() && !$isUserAdmin) {
463-
throw new NotPermittedException();
464-
}
465466

466467
$result = $this->settingsService->uploadFile($settingsUrl, $fileContent, $userId);
467468

0 commit comments

Comments
 (0)