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

fix(preview-generator): Throw exception before dividing by zero when generating previews #36692

Merged
merged 1 commit into from
May 16, 2023

Conversation

tcitworld
Copy link
Member

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

ErrorException: Warning: Division by zero
#11 /var/www/nc/nextcloud-25.0.1/lib/private/Preview/Generator.php(516): OC\Preview\Generator::generatePreview
#10 /var/www/nc/nextcloud-25.0.1/lib/private/Preview/Generator.php(208): OC\Preview\Generator::generatePreviews
#9 /var/www/nc/nextcloud-25.0.1/lib/private/Preview/Generator.php(114): OC\Preview\Generator::getPreview
#8 /var/www/nc/nextcloud-25.0.1/lib/private/PreviewManager.php(185): OC\PreviewManager::getPreview
#7 /var/www/nc/nextcloud-25.0.1/core/Controller/PreviewController.php(144): OC\Core\Controller\PreviewController::fetchPreview
#6 /var/www/nc/nextcloud-25.0.1/core/Controller/PreviewController.php(113): OC\Core\Controller\PreviewController::getPreviewByFileId

Checklist

…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]>
@tcitworld tcitworld requested a review from a team February 13, 2023 15:50
@tcitworld tcitworld self-assigned this Feb 13, 2023
@tcitworld tcitworld requested review from ArtificialOwl, icewind1991 and blizzz and removed request for a team February 13, 2023 15:50
@tcitworld tcitworld marked this pull request as ready for review February 13, 2023 15:51
Copy link
Contributor

@szaimen szaimen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but didnt test

@szaimen szaimen added this to the Nextcloud 27 milestone May 16, 2023
@szaimen szaimen merged commit 6608f84 into master May 16, 2023
@szaimen szaimen deleted the throw-exception-to-avoid-division-by-zero branch May 16, 2023 22:14
@blizzz blizzz mentioned this pull request May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants