mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-18 05:20:50 +01:00
Merge pull request #15791 from nextcloud/carl/deprecated-filenameisblacklisted
chore: Port away from deprecated Filesystem::isFileBlacklisted
This commit is contained in:
commit
080731958a
4 changed files with 19 additions and 19 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);
|
||||
|
|
@ -53,11 +54,7 @@ class TempAvatarController extends OCSController {
|
|||
);
|
||||
}
|
||||
|
||||
if (
|
||||
$files['error'][0] === 0
|
||||
&& is_uploaded_file($files['tmp_name'][0])
|
||||
&& !Filesystem::isFileBlacklisted($files['tmp_name'][0])
|
||||
) {
|
||||
if ($files['error'][0] === 0 && is_uploaded_file($files['tmp_name'][0])) {
|
||||
if ($files['size'][0] > 20 * 1024 * 1024) {
|
||||
return new DataResponse(
|
||||
['message' => $this->l->t('File is too big')],
|
||||
|
|
@ -82,7 +79,7 @@ class TempAvatarController extends OCSController {
|
|||
|
||||
if (!$image->valid()) {
|
||||
return new DataResponse(
|
||||
['data' => ['message' => $this->l->t('Invalid image')]],
|
||||
['message' => $this->l->t('Invalid image')],
|
||||
Http::STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
|
@ -90,7 +87,7 @@ class TempAvatarController extends OCSController {
|
|||
$mimeType = $image->mimeType();
|
||||
if ($mimeType !== 'image/jpeg' && $mimeType !== 'image/png') {
|
||||
return new DataResponse(
|
||||
['data' => ['message' => $this->l->t('Unknown filetype')]],
|
||||
['message' => $this->l->t('Unknown filetype')],
|
||||
Http::STATUS_BAD_REQUEST
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -48,11 +49,7 @@ class AvatarService {
|
|||
throw new InvalidArgumentException($this->l->t('No image file provided'));
|
||||
}
|
||||
|
||||
if (
|
||||
$file['error'] !== 0
|
||||
|| !is_uploaded_file($file['tmp_name'])
|
||||
|| Filesystem::isFileBlacklisted($file['tmp_name'])
|
||||
) {
|
||||
if ($file['error'] !== 0 || !is_uploaded_file($file['tmp_name'])) {
|
||||
throw new InvalidArgumentException($this->l->t('Invalid file provided'));
|
||||
}
|
||||
if ($file['size'] > 20 * 1024 * 1024) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -32,6 +33,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 {
|
||||
|
|
@ -44,6 +46,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,
|
||||
|
|
@ -52,6 +55,7 @@ class AvatarServiceTest extends TestCase {
|
|||
$this->roomService,
|
||||
$this->avatarManager,
|
||||
$this->emojiService,
|
||||
$this->filenameValidator,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="6.12.1@e71404b0465be25cf7f8a631b298c01c5ddd864f">
|
||||
<files psalm-version="6.13.1@1e3b7f0a8ab32b23197b91107adc0a7ed8a05b51">
|
||||
<file src="lib/AppInfo/Application.php">
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[BeforeTemplateRenderedEvent]]></code>
|
||||
|
|
@ -61,8 +61,12 @@
|
|||
</NullArgument>
|
||||
</file>
|
||||
<file src="lib/Controller/TempAvatarController.php">
|
||||
<MissingDependency>
|
||||
<code><![CDATA[\OCP\Image]]></code>
|
||||
</MissingDependency>
|
||||
<UndefinedClass>
|
||||
<code><![CDATA[Filesystem]]></code>
|
||||
<code><![CDATA[$e]]></code>
|
||||
<code><![CDATA[NotSquareException]]></code>
|
||||
</UndefinedClass>
|
||||
</file>
|
||||
<file src="lib/Federation/Authenticator.php">
|
||||
|
|
@ -138,10 +142,8 @@
|
|||
<file src="lib/Service/AvatarService.php">
|
||||
<MissingDependency>
|
||||
<code><![CDATA[\OCP\Image]]></code>
|
||||
<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