Skip to content

ExifProvider.php: handle unhandled exception - #35932

Closed
luxifr wants to merge 2 commits into
nextcloud:masterfrom
luxifr:patch-1
Closed

ExifProvider.php: handle unhandled exception#35932
luxifr wants to merge 2 commits into
nextcloud:masterfrom
luxifr:patch-1

Conversation

@luxifr

Copy link
Copy Markdown

Signed-off-by: luxifr luxifer@luxifer.fyi

Summary

Handle unhandled exception to keep files:scan run from crashing when it encounters a file with invalid exif data.

Checklist

Signed-off-by: luxifr <luxifer@luxifer.fyi>
Comment threadlib/private/Metadata/Provider/ExifProvider.php Outdated
Signed-off-by: luxifr <luxifer@luxifer.fyi>
@szaimenszaimen added bug 3. to review Waiting for reviews labels Jan 1, 2023
@szaimenszaimen added this to the Nextcloud 26 milestone Jan 1, 2023
@szaimen
szaimen requested review from a team, ArtificialOwl, blizzz and icewind1991 and removed request for a teamJanuary 1, 2023 11:29
@PVince81
PVince81 requested a review from artongeJanuary 4, 2023 15:33
@blizzzblizzz mentioned this pull request Feb 1, 2023
$sizeResult = getimagesizefromstring($file->getContent());
try {
$sizeResult = getimagesizefromstring($file->getContent());
} catch (\Throwable $ex) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think this will work:

php > try {getimagesize('foobar');} catch(\Throwable $e){}
PHP Warning: getimagesize(foobar): Failed to open stream: No such file or directory in php shell code on line 1

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Probably same reason as in #36420 (comment)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would work from scan command because scan command converts warning into Exception, but that’s really ugly. It should be handled in Scan command as it is the one doing the conversion.

@skjnldsvskjnldsv mentioned this pull request Feb 23, 2023
@blizzzblizzz mentioned this pull request Mar 7, 2023
@blizzzblizzz modified the milestones: Nextcloud 26, Nextcloud 27Mar 9, 2023
Comment on lines +72 to +74
$sizeResult = getimagesizefromstring($file->getContent());
} catch (\Throwable $ex) {
$this->logger->warning("Couldn't get image for ".$file->getId(), ['exception' => $ex]);

@szaimenszaimenApr 15, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as in https://github.com/nextcloud/server/pull/36420/files

Suggested change
$sizeResult = getimagesizefromstring($file->getContent());
} catch (\Throwable$ex) {
$this->logger->warning("Couldn't get image for ".$file->getId(), ['exception' => $ex]);
$sizeResult = @getimagesizefromstring($file->getContent());
} catch (\Exception$ex) {
$this->logger->info("Couldn't get image for ".$file->getId(), ['exception' => $ex]);

$sizeResult = getimagesizefromstring($file->getContent());
try {
$sizeResult = getimagesizefromstring($file->getContent());
} catch (\Throwable $ex) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This would work from scan command because scan command converts warning into Exception, but that’s really ugly. It should be handled in Scan command as it is the one doing the conversion.

@come-nc

Copy link
Copy Markdown
Contributor

See #37944 instead

@szaimenszaimen closed this Apr 27, 2023
@digidax

Copy link
Copy Markdown

Bug still present in 26.0.2 when using Android App Folder Sync:
grafik

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviewsbug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: unhandled exception in ExifProvider crashes scan run

8 participants

@luxifr@come-nc@digidax@marcelklehr@shyim@artonge@szaimen@blizzz