Skip to content

Commit

Permalink
fix: add typecast for mimetype
Browse files Browse the repository at this point in the history
getMimetypeById expectes an integer and is strictly typed since 29 and therefore we need a typecast as additional hardening.

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb committed Jun 4, 2024
1 parent 8d5b8fc commit b442ae9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions lib/Album/AlbumMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getForUser(string $userId): array {
return new AlbumInfo((int)$row['album_id'], $userId, $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']);
}, $rows);
}

/**
* @param string $albumName
* @param string $userName
Expand Down Expand Up @@ -205,10 +205,8 @@ public function getForAlbumIdAndUserWithFiles(int $albumId, string $userId): arr

$files = [];
foreach ($rows as $row) {
$albumId = (int)$row['album_id'];
if ($row['fileid']) {
$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$mimeType = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype']);
$files[] = new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}
}
Expand All @@ -233,8 +231,7 @@ public function getForAlbumIdAndFileId(int $albumId, int $fileId): AlbumFile {
->andWhere($query->expr()->eq('file_id', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
$row = $query->executeQuery()->fetchAll()[0];

$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$mimeType = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype']);
return new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}

Expand Down Expand Up @@ -533,8 +530,7 @@ public function getSharedAlbumsForCollaboratorWithFiles(string $collaboratorId,
foreach ($rows as $row) {
$albumId = (int)$row['album_id'];
if ($row['fileid']) {
$mimeId = $row['mimetype'];
$mimeType = $this->mimeTypeLoader->getMimetypeById($mimeId);
$mimeType = $this->mimeTypeLoader->getMimetypeById((int)$row['mimetype']);
$filesByAlbum[$albumId][] = new AlbumFile((int)$row['fileid'], $row['file_name'], $mimeType, (int)$row['size'], (int)$row['mtime'], $row['etag'], (int)$row['added'], $row['owner']);
}

Expand Down

0 comments on commit b442ae9

Please sign in to comment.