fix: Use Ruby/Rails internals to create human readable file names#3597
Merged
fix: Use Ruby/Rails internals to create human readable file names#3597
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3597 +/- ##
=======================================
Coverage 97.46% 97.47%
=======================================
Files 314 314
Lines 8218 8225 +7
=======================================
+ Hits 8010 8017 +7
Misses 208 208 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mamhoff
approved these changes
Jan 27, 2026
b265939 to
affc2d6
Compare
Use Ruby's `File.basename` and Rails' `humanize` to create the first initial human readable `name` of `Attachment`s and `Picture`s. Before we where using our own brittle Regexp, that expected the file suffix to be known from it's mime type. This is not the case for unknown mimetypes. We also move the name conversion before filename sanitization in order to get a nice human readable name and not escape characters. Since the name is not used to load the file and all output is escaped in Rails by default, this is fine. Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
affc2d6 to
c72a016
Compare
This was referenced Feb 4, 2026
Closed
Closed
Closed
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this pull request for?
Use Ruby's
File.basenameand Rails'humanizeto create the first initial human readablenameofAttachments andPictures.Before we where using our own brittle Regexp, that expected the file suffix to be known from it's mime type. This is not the case for unknown mimetypes.
We also move the name conversion before filename sanitization in order to get a nice human readable name and not escape characters. Since the name is not used to load the file and all output is escaped in Rails by default, this is fine.
Checklist