Skip to content

fix(preview): Validate preview MIME type#58793

Merged
kesselb merged 1 commit intomasterfrom
validatePreviewMimeType
Mar 9, 2026
Merged

fix(preview): Validate preview MIME type#58793
kesselb merged 1 commit intomasterfrom
validatePreviewMimeType

Conversation

@solracsf
Copy link
Member

@solracsf solracsf commented Mar 8, 2026

Summary

When generating previews, malformed dimensions can produce a preview image with a null MIME type.

This validates the preview object and its MIME type after resize/crop operations and before creating the DB record. If the preview is invalid or has a null MIME type an InvalidArgumentException is thrown and the file is skipped instead of crashing.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

@solracsf solracsf added this to the Nextcloud 34 milestone Mar 8, 2026
@solracsf solracsf requested a review from a team as a code owner March 8, 2026 17:51
@solracsf solracsf added the bug label Mar 8, 2026
@solracsf solracsf requested review from ArtificialOwl and salmart-dev and removed request for a team March 8, 2026 17:51
@solracsf solracsf added the 3. to review Waiting for reviews label Mar 8, 2026
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the validatePreviewMimeType branch from b642762 to 304c9fb Compare March 8, 2026 17:57
@CarlSchwan
Copy link
Member

/backport to stable33

@kesselb kesselb merged commit 92cf64f into master Mar 9, 2026
185 of 187 checks passed
@kesselb kesselb deleted the validatePreviewMimeType branch March 9, 2026 16:20
@backportbot
Copy link

backportbot bot commented Mar 9, 2026

The backport to stable33 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable33
git pull origin stable33

# Create the new backport branch
git checkout -b backport/58793/stable33

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick 304c9fbc

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/58793/stable33

Error: Failed to push branch backport/58793/stable33: remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/nextcloud/server.git/'


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@solracsf
Copy link
Member Author

solracsf commented Mar 9, 2026

/backport to stable33

@solracsf
Copy link
Member Author

solracsf commented Mar 9, 2026

/backport to stable32

@backportbot
Copy link

backportbot bot commented Mar 9, 2026

The backport to stable32 failed. Please do this backport manually.

# Switch to the target branch and update it
git checkout stable32
git pull origin stable32

# Create the new backport branch
git checkout -b backport/58793/stable32

# Cherry pick the change from the commit sha1 of the change against the default branch
# This might cause conflicts, resolve them
git cherry-pick 304c9fbc

# Push the cherry pick commit to the remote repository and open a pull request
git push origin backport/58793/stable32

Error: Failed to check for changes with origin/stable32: No changes found in backport branch


Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

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.

[Bug]: preview generation crashes on image files when generated preview has null MIME type

3 participants