Skip to content

Commit 8e60fe8

Browse files
authored
Merge pull request #7990 from nextcloud/fix/board-preference-permissions
fix: board notify-due
2 parents 5f9fcf4 + aecbf1b commit 8e60fe8

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

lib/Controller/ConfigController.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
namespace OCA\Deck\Controller;
99

10+
use OCA\Deck\Db\Acl;
11+
use OCA\Deck\Db\BoardMapper;
1012
use OCA\Deck\Service\ConfigService;
13+
use OCA\Deck\Service\PermissionService;
1114
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
1215
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
1316
use OCP\AppFramework\Http\DataResponse;
@@ -20,6 +23,8 @@ public function __construct(
2023
$AppName,
2124
IRequest $request,
2225
private ConfigService $configService,
26+
private PermissionService $permissionService,
27+
private BoardMapper $boardMapper,
2328
) {
2429
parent::__construct($AppName, $request);
2530
}
@@ -33,6 +38,14 @@ public function get(): DataResponse {
3338
#[NoAdminRequired]
3439
#[NoCSRFRequired]
3540
public function setValue(string $key, mixed $value): DataResponse|NotFoundResponse {
41+
if (preg_match('/^board:(\d+):/', $key, $matches) === 1) {
42+
$this->permissionService->checkPermission(
43+
$this->boardMapper,
44+
(int)$matches[1],
45+
Acl::PERMISSION_EDIT,
46+
);
47+
}
48+
3649
$result = $this->configService->set($key, $value);
3750
if ($result === null) {
3851
return new NotFoundResponse();

lib/Service/ConfigService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ public function set($key, $value) {
183183
$result = $value;
184184
break;
185185
case 'board':
186-
[$boardId, $boardConfigKey] = explode(':', $key);
186+
// extra check that user only send one of the allowed board settings and not something random
187+
$parts = explode(':', $key, 3);
188+
if (count($parts) < 3) {
189+
break;
190+
}
191+
$boardConfigKey = $parts[2];
187192
if ($boardConfigKey === 'notify-due' && !in_array($value, [self::SETTING_BOARD_NOTIFICATION_DUE_ALL, self::SETTING_BOARD_NOTIFICATION_DUE_ASSIGNED, self::SETTING_BOARD_NOTIFICATION_DUE_OFF], true)) {
188193
throw new BadRequestException('Board notification option must be one of: off, assigned, all');
189194
}

0 commit comments

Comments
 (0)