Skip to content

fix: Use Ruby/Rails internals to create human readable file names#3597

Merged
tvdeyen merged 1 commit intomainfrom
fix-filename-conversion
Jan 28, 2026
Merged

fix: Use Ruby/Rails internals to create human readable file names#3597
tvdeyen merged 1 commit intomainfrom
fix-filename-conversion

Conversation

@tvdeyen
Copy link
Member

@tvdeyen tvdeyen commented Jan 27, 2026

What is this pull request for?

Use Ruby's File.basename and Rails' humanize to create the first initial human readable name of Attachments and Pictures.

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

  • I have followed Pull Request guidelines
  • I have added a detailed description into each commit message
  • I have added tests to cover this change

@tvdeyen tvdeyen added this to the 8.1 milestone Jan 27, 2026
@tvdeyen tvdeyen requested a review from a team as a code owner January 27, 2026 18:04
@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.47%. Comparing base (bddb4cd) to head (c72a016).
⚠️ Report is 2 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvdeyen tvdeyen marked this pull request as draft January 27, 2026 20:30
@tvdeyen tvdeyen self-assigned this Jan 27, 2026
@tvdeyen tvdeyen force-pushed the fix-filename-conversion branch from b265939 to affc2d6 Compare January 28, 2026 07:38
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>
@tvdeyen tvdeyen force-pushed the fix-filename-conversion branch from affc2d6 to c72a016 Compare January 28, 2026 07:40
@tvdeyen tvdeyen changed the title Use Ruby/Rails internals to create human readable file names fix: Use Ruby/Rails internals to create human readable file names Jan 28, 2026
@tvdeyen tvdeyen marked this pull request as ready for review January 28, 2026 07:41
@tvdeyen tvdeyen added the bug label Jan 28, 2026
@tvdeyen tvdeyen merged commit d9112f4 into main Jan 28, 2026
23 checks passed
@tvdeyen tvdeyen deleted the fix-filename-conversion branch January 28, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants