Skip to content
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
fix(preview-generator): Throw exception before dividing by zero when …
…generating previews

If the maximum preview generated gives some kind of invalid IImage, it's dimentions and filename can be set to zero.
And then later we do a division by zero to keep the aspect ratio of the previews.

Signed-off-by: Thomas Citharel <[email protected]>
  • Loading branch information
tcitworld committed Feb 13, 2023
commit e60888d98892be22477ea6ace68255d7202dbec8
4 changes: 4 additions & 0 deletions lib/private/Preview/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ public function generatePreviews(File $file, array $specifications, $mimeType =

[$maxWidth, $maxHeight] = $this->getPreviewSize($maxPreview, $previewVersion);

if ($maxWidth <= 0 || $maxHeight <= 0) {
throw new NotFoundException('The maximum preview sizes are zero or less pixels');
}

$preview = null;

foreach ($specifications as $specification) {
Expand Down