Skip to content

Commit 08585d9

Browse files
authored
Merge pull request #7995 from nextcloud/backport/7990/stable29
[stable29] fix: board notify-due
2 parents 350ecbb + dbd1856 commit 08585d9

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
@@ -23,7 +23,10 @@
2323

2424
namespace OCA\Deck\Controller;
2525

26+
use OCA\Deck\Db\Acl;
27+
use OCA\Deck\Db\BoardMapper;
2628
use OCA\Deck\Service\ConfigService;
29+
use OCA\Deck\Service\PermissionService;
2730
use OCP\AppFramework\Http\DataResponse;
2831
use OCP\AppFramework\Http\NotFoundResponse;
2932
use OCP\AppFramework\OCSController;
@@ -34,6 +37,8 @@ public function __construct(
3437
$AppName,
3538
IRequest $request,
3639
private ConfigService $configService,
40+
private PermissionService $permissionService,
41+
private BoardMapper $boardMapper,
3742
) {
3843
parent::__construct($AppName, $request);
3944
}
@@ -51,6 +56,14 @@ public function get(): DataResponse {
5156
* @NoAdminRequired
5257
*/
5358
public function setValue(string $key, $value) {
59+
if (preg_match('/^board:(\d+):/', $key, $matches) === 1) {
60+
$this->permissionService->checkPermission(
61+
$this->boardMapper,
62+
(int)$matches[1],
63+
Acl::PERMISSION_EDIT,
64+
);
65+
}
66+
5467
$result = $this->configService->set($key, $value);
5568
if ($result === null) {
5669
return new NotFoundResponse();

lib/Service/ConfigService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ public function set($key, $value) {
174174
$result = $value;
175175
break;
176176
case 'board':
177-
[$boardId, $boardConfigKey] = explode(':', $key);
177+
// extra check that user only send one of the allowed board settings and not something random
178+
$parts = explode(':', $key, 3);
179+
if (count($parts) < 3) {
180+
break;
181+
}
182+
$boardConfigKey = $parts[2];
178183
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)) {
179184
throw new BadRequestException('Board notification option must be one of: off, assigned, all');
180185
}

0 commit comments

Comments
 (0)