0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-03-13 16:03:55 +00:00

fix(workflow): Check tag attribute

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2023-03-16 08:41:18 +01:00
parent bcc9ee4011
commit ce8ec36184
No known key found for this signature in database
GPG key ID: C400AAF20C1BB6FC

View file

@ -30,7 +30,10 @@ use OCA\Files_Sharing\SharedStorage;
use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Cache\ICache;
use OCP\Files\IHomeStorage;
use OCP\IGroupManager;
use OCP\IL10N;
use OCP\IUser;
use OCP\IUserSession;
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\SystemTag\TagNotFoundException;
@ -55,16 +58,23 @@ class FileSystemTags implements ICheck, IFileCheck {
/** @var ISystemTagObjectMapper */
protected $systemTagObjectMapper;
/** @var IUserSession */
protected $userSession;
/** @var IGroupManager */
protected $groupManager;
/**
* @param IL10N $l
* @param ISystemTagManager $systemTagManager
* @param ISystemTagObjectMapper $systemTagObjectMapper
*/
public function __construct(IL10N $l, ISystemTagManager $systemTagManager, ISystemTagObjectMapper $systemTagObjectMapper) {
public function __construct(
IL10N $l,
ISystemTagManager $systemTagManager,
ISystemTagObjectMapper $systemTagObjectMapper,
IUserSession $userSession,
IGroupManager $groupManager
) {
$this->l = $l;
$this->systemTagManager = $systemTagManager;
$this->systemTagObjectMapper = $systemTagObjectMapper;
$this->userSession = $userSession;
$this->groupManager = $groupManager;
}
/**
@ -88,7 +98,18 @@ class FileSystemTags implements ICheck, IFileCheck {
}
try {
$this->systemTagManager->getTagsByIds($value);
$tags = $this->systemTagManager->getTagsByIds($value);
$user = $this->userSession->getUser();
$isAdmin = $user instanceof IUser && $this->groupManager->isAdmin($user->getUID());
if (!$isAdmin) {
foreach ($tags as $tag) {
if (!$tag->isUserVisible()) {
throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 4);
}
}
}
} catch (TagNotFoundException $e) {
throw new \UnexpectedValueException($this->l->t('The given tag id is invalid'), 2);
} catch (\InvalidArgumentException $e) {