mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
chore: Port away from deprecated Filesystem::isFileBlacklisted
Signed-off-by: Carl Schwan <carl.schwan@nextcloud.com>
This commit is contained in:
parent
98cd3a235a
commit
4141e107d6
4 changed files with 10 additions and 12 deletions
|
|
@ -8,13 +8,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Talk\Controller;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\NotSquareException;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\Attribute\NoAdminRequired;
|
||||
use OCP\AppFramework\Http\Attribute\OpenAPI;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCSController;
|
||||
use OCP\Files\IFilenameValidator;
|
||||
use OCP\IAvatarManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\IRequest;
|
||||
|
|
@ -28,6 +28,7 @@ class TempAvatarController extends OCSController {
|
|||
private IAvatarManager $avatarManager,
|
||||
private IL10N $l,
|
||||
private LoggerInterface $logger,
|
||||
private IFilenameValidator $filenameValidator,
|
||||
private string $userId,
|
||||
) {
|
||||
parent::__construct($appName, $request);
|
||||
|
|
@ -56,7 +57,7 @@ class TempAvatarController extends OCSController {
|
|||
if (
|
||||
$files['error'][0] === 0
|
||||
&& is_uploaded_file($files['tmp_name'][0])
|
||||
&& !Filesystem::isFileBlacklisted($files['tmp_name'][0])
|
||||
&& $this->filenameValidator->isFilenameValid($files['tmp_name'][0])
|
||||
) {
|
||||
if ($files['size'][0] > 20 * 1024 * 1024) {
|
||||
return new DataResponse(
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ declare(strict_types=1);
|
|||
namespace OCA\Talk\Service;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use OC\Files\Filesystem;
|
||||
use OCA\Talk\Room;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\IFilenameValidator;
|
||||
use OCP\Files\NotFoundException;
|
||||
use OCP\Files\SimpleFS\InMemoryFile;
|
||||
use OCP\Files\SimpleFS\ISimpleFile;
|
||||
|
|
@ -36,6 +36,7 @@ class AvatarService {
|
|||
private RoomService $roomService,
|
||||
private IAvatarManager $avatarManager,
|
||||
private EmojiService $emojiService,
|
||||
private IFilenameValidator $filenameValidator,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ class AvatarService {
|
|||
if (
|
||||
$file['error'] !== 0
|
||||
|| !is_uploaded_file($file['tmp_name'])
|
||||
|| Filesystem::isFileBlacklisted($file['tmp_name'])
|
||||
|| !$this->filenameValidator->isFilenameValid($file['tmp_name'])
|
||||
) {
|
||||
throw new InvalidArgumentException($this->l->t('Invalid file provided'));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ use OCA\Talk\Service\AvatarService;
|
|||
use OCA\Talk\Service\EmojiService;
|
||||
use OCA\Talk\Service\RoomService;
|
||||
use OCP\Files\IAppData;
|
||||
use OCP\Files\IFilenameValidator;
|
||||
use OCP\IAvatarManager;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
|
|
@ -33,6 +34,7 @@ class AvatarServiceTest extends TestCase {
|
|||
protected RoomService&MockObject $roomService;
|
||||
protected IAvatarManager&MockObject $avatarManager;
|
||||
protected EmojiService $emojiService;
|
||||
protected IFilenameValidator $filenameValidator;
|
||||
protected ?AvatarService $service = null;
|
||||
|
||||
public function setUp(): void {
|
||||
|
|
@ -45,6 +47,7 @@ class AvatarServiceTest extends TestCase {
|
|||
$this->roomService = $this->createMock(RoomService::class);
|
||||
$this->avatarManager = $this->createMock(IAvatarManager::class);
|
||||
$this->emojiService = Server::get(EmojiService::class);
|
||||
$this->filenameValidator = Server::get(IFilenameValidator::class);
|
||||
$this->service = new AvatarService(
|
||||
$this->appData,
|
||||
$this->l,
|
||||
|
|
@ -53,6 +56,7 @@ class AvatarServiceTest extends TestCase {
|
|||
$this->roomService,
|
||||
$this->avatarManager,
|
||||
$this->emojiService,
|
||||
$this->filenameValidator,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@
|
|||
<code><![CDATA[null]]></code>
|
||||
</NullArgument>
|
||||
</file>
|
||||
<file src="lib/Controller/TempAvatarController.php">
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[Filesystem]]></code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/Federation/Authenticator.php">
|
||||
<NoInterfaceProperties>
|
||||
<code><![CDATA[$this->request->server]]></code>
|
||||
|
|
@ -139,9 +134,6 @@
|
|||
<MissingDependency>
|
||||
<code><![CDATA[\OCP\Image]]></code>
|
||||
</MissingDependency>
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[Filesystem]]></code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/Service/RecordingService.php">
|
||||
<LessSpecificReturnStatement>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue