Skip to content

Commit 315cd89

Browse files
authored
Merge pull request #7994 from nextcloud/backport/7990/stable30
[stable30] fix: board notify-due
2 parents 3150223 + abbe703 commit 315cd89

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
@@ -6,7 +6,10 @@
66

77
namespace OCA\Deck\Controller;
88

9+
use OCA\Deck\Db\Acl;
10+
use OCA\Deck\Db\BoardMapper;
911
use OCA\Deck\Service\ConfigService;
12+
use OCA\Deck\Service\PermissionService;
1013
use OCP\AppFramework\Http\DataResponse;
1114
use OCP\AppFramework\Http\NotFoundResponse;
1215
use OCP\AppFramework\OCSController;
@@ -17,6 +20,8 @@ public function __construct(
1720
$AppName,
1821
IRequest $request,
1922
private ConfigService $configService,
23+
private PermissionService $permissionService,
24+
private BoardMapper $boardMapper,
2025
) {
2126
parent::__construct($AppName, $request);
2227
}
@@ -34,6 +39,14 @@ public function get(): DataResponse {
3439
* @NoAdminRequired
3540
*/
3641
public function setValue(string $key, $value) {
42+
if (preg_match('/^board:(\d+):/', $key, $matches) === 1) {
43+
$this->permissionService->checkPermission(
44+
$this->boardMapper,
45+
(int)$matches[1],
46+
Acl::PERMISSION_EDIT,
47+
);
48+
}
49+
3750
$result = $this->configService->set($key, $value);
3851
if ($result === null) {
3952
return new NotFoundResponse();

lib/Service/ConfigService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,12 @@ public function set($key, $value) {
157157
$result = $value;
158158
break;
159159
case 'board':
160-
[$boardId, $boardConfigKey] = explode(':', $key);
160+
// extra check that user only send one of the allowed board settings and not something random
161+
$parts = explode(':', $key, 3);
162+
if (count($parts) < 3) {
163+
break;
164+
}
165+
$boardConfigKey = $parts[2];
161166
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)) {
162167
throw new BadRequestException('Board notification option must be one of: off, assigned, all');
163168
}

0 commit comments

Comments
 (0)