Skip to content

AO3-7473 Possible to upload unusable collection/skin icon#5825

Open
cinderbrick1212 wants to merge 2 commits into
otwcode:masterfrom
cinderbrick1212:master
Open

AO3-7473 Possible to upload unusable collection/skin icon#5825
cinderbrick1212 wants to merge 2 commits into
otwcode:masterfrom
cinderbrick1212:master

Conversation

@cinderbrick1212
Copy link
Copy Markdown

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-7473

Purpose

I updated the allowed image formats for Skin and Collection icons to prevent 500 errors.

Previously, the validation accepted any image/* MIME type, which caused server crashes when the image processing library attempted to resize unsupported vector formats like SVGs. I updated app/models/skin.rb and app/models/collection.rb to strictly allow image/gif, image/jpeg, and image/png, mirroring the safer validation that is already in place for Pseud icons.

Testing Instructions

  1. Log in to the application.
  2. Navigate to the page to create or edit a Collection.
  3. Attempt to upload an .svg file (or another unsupported image format) as the icon and submit the form.
  4. Verify that the upload is blocked and a standard validation error is displayed, rather than throwing a 500 error.
  5. Repeat steps 2-4 for creating or editing a Skin.
  6. Upload a valid .png, .jpg, or .gif to ensure standard uploads still process correctly for both models.

Credit

Anish Kapoor (he/him)

Copilot AI review requested due to automatic review settings May 18, 2026 20:22
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR prevents 500 errors during Skin/Collection icon processing by restricting icon uploads to raster image MIME types that the resizing pipeline can safely handle (GIF/JPEG/PNG), matching the existing Pseud icon validation approach.

Changes:

  • Tightened Skin icon allowed_formats from any image/* MIME type to image/gif, image/jpeg, and image/png.
  • Tightened Collection icon allowed_formats from any image/* MIME type to image/gif, image/jpeg, and image/png.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
app/models/skin.rb Restricts Skin icon MIME types to GIF/JPEG/PNG to avoid unsupported formats causing processing errors.
app/models/collection.rb Restricts Collection icon MIME types to GIF/JPEG/PNG to avoid unsupported formats causing processing errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/models/skin.rb
Comment on lines 57 to 60
validates :icon, attachment: {
allowed_formats: %r{image/\S+},
allowed_formats: %w[image/gif image/jpeg image/png],
maximum_size: ArchiveConfig.ICON_SIZE_KB_MAX.kilobytes
}
Comment thread app/models/collection.rb
Comment on lines 12 to 15
validates :icon, attachment: {
allowed_formats: %r{image/\S+},
allowed_formats: %w[image/gif image/jpeg image/png],
maximum_size: ArchiveConfig.ICON_SIZE_KB_MAX.kilobytes
}
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.

2 participants