Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter malformed accesslist #275

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading