Skip to content

Commit

Permalink
filter malformed accesslist
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl authored and backportbot[bot] committed Aug 19, 2024
1 parent f7e7162 commit 5e769fe
Showing 1 changed file with 12 additions and 53 deletions.
65 changes: 12 additions & 53 deletions lib/Service/LocalFilesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,68 +37,27 @@
use OCA\Files_FullTextSearch\Exceptions\KnownFileSourceException;
use OCA\Files_FullTextSearch\Model\FilesDocument;
use OCA\Files_FullTextSearch\Model\FileShares;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\FullTextSearch\Model\IDocumentAccess;
use OCP\IGroupManager;
use OCP\IUserManager;
use OCP\Share\IManager;
use OCP\Share\IShare;
use Psr\Log\LoggerInterface;

/**
* Class LocalFilesService
*
* @package OCA\Files_FullTextSearch\Service
*/
class LocalFilesService {


/** @var IRootFolder */
private $rootFolder;

/** @var IGroupManager */
private $groupManager;

/** @var IUserManager */
private $userManager;

/** @var IManager */
private $shareManager;

/** @var SharesRequest */
private $sharesRequest;

/** @var ConfigService */
private $configService;

/** @var MiscService */
private $miscService;


/**
* LocalFilesService constructor.
*
* @param IRootFolder $rootFolder
* @param IGroupManager $groupManager
* @param IUserManager $userManager
* @param IManager $shareManager
* @param SharesRequest $sharesRequest
* @param ConfigService $configService
* @param MiscService $miscService
*/
public function __construct(
IRootFolder $rootFolder, IGroupManager $groupManager, IUserManager $userManager,
IManager $shareManager, SharesRequest $sharesRequest, ConfigService $configService,
MiscService $miscService
private IGroupManager $groupManager,
private IUserManager $userManager,
private IManager $shareManager,
private SharesRequest $sharesRequest,
private LoggerInterface $logger,
) {
$this->rootFolder = $rootFolder;
$this->groupManager = $groupManager;
$this->userManager = $userManager;
$this->shareManager = $shareManager;

$this->sharesRequest = $sharesRequest;
$this->configService = $configService;
$this->miscService = $miscService;
}


Expand Down Expand Up @@ -163,16 +122,16 @@ public function getShareUsersFromFile(Node $file, array &$users) {
return;
}

if (!array_key_exists('users', $shares)) {
return;
}

foreach ($shares['users'] as $user => $node) {
foreach ($shares['users'] ?? [] as $user => $node) {
if (!is_string($user)) {
$this->logger->warning('malformed access list: ' . json_encode($shares));
continue;
}
if (in_array($user, $users) || $this->userManager->get($user) === null) {
continue;
}

array_push($users, $user);
$users[] = $user;
}
}

Expand Down

0 comments on commit 5e769fe

Please sign in to comment.