Skip to content

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

Closed
cinderbrick1212 wants to merge 0 commit into
otwcode:masterfrom
cinderbrick1212:master
Closed

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

Conversation

@cinderbrick1212

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown

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
}
@sarken

sarken commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Hi, Anish Kapoor!

Thank you so much for this pull request. Someone will be along to review it soon. (Just as a heads up, we don't generally allow the use of AI, and Copilot reviews should be disabled for this project.)

In the meantime, we've updated the Jira issue status to In Review so no one mistakenly creates a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)."

Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you.

Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above.

@brianjaustin brianjaustin left a comment

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.

Thanks for the PR! Could you add some automated tests to ensure that indeed non-supported types are rejected?

@cinderbrick1212

Copy link
Copy Markdown
Contributor Author

Hi, Anish Kapoor!

Thank you so much for this pull request. Someone will be along to review it soon. (Just as a heads up, we don't generally allow the use of AI, and Copilot reviews should be disabled for this project.)

In the meantime, we've updated the Jira issue status to In Review so no one mistakenly creates a duplicate pull request. If you'd like the ability to comment on, assign, and transition issues in the future, you're welcome to create a Jira account! It makes things a bit easier for us on the organizational side if the Full Name on your Jira account either closely matches the name you'd like us to credit in the release notes or includes it in parentheses, e.g. "Nickname (CREDIT NAME)."

Once you've done that (or if you've already done it -- Jira has been unreliable about showing us new accounts in the admin panel lately), you can either reply here or send an email to otw-coders@transformativeworks.org with your account name and email address and we'll set up the permissions for you.

Thanks again for contributing! If you have any questions, you can contact us at the same email address listed above.

Understood! Copilot is now disabled, and I've just emailed you my Jira account info. Thanks for your help!

CorinaNC pushed a commit to CorinaNC/otwarchive that referenced this pull request Jul 2, 2026
…de#5825)

The config exists at the model/resource class from the registerable
module, but it was not being honored, instead we were directly relying
on the main Devise config.

Now this can be configured and honored per-model/resource class, as
expected.

This is similar to otwcode#5429 and `sign_in_after_reset_password` fix.
@Bilka2 Bilka2 closed this Aug 12, 2026
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.

5 participants