Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow dot in attachment name #131

Merged

Conversation

stevenharman
Copy link
Collaborator

@stevenharman stevenharman commented Mar 2, 2024

The primary change (in its own commit for clarity) is to allow dot (.) characters in attachment file name. The default constraint on segments does not allow dots, so requests for attachments with a dot in the file name wouldn't find a route, resulting in a 404 out of the Rails router.

The other commits are appeasing Rubocop.

An alternative approach

There are likely other characters allowed in file names, but disallowed in the path of a URL. If we'd also like to handle those, we could change the way we pass the attachment file name to use a query param. So the route would change to something like:

GET /letter_opener/:id/attachment?filename=some.file.ext

The filename param would also be URL encoded to make it safe. If you like this idea, I can adjust this PR to use that approach. Or, just roll with this one as-is and deal with that later, if someone needs it.

@stevenharman stevenharman changed the title Allow dot in attachement name Allow dot in attachment name Mar 2, 2024
@stevenharman stevenharman force-pushed the allow_dot_in_attachement_name branch from caf740a to a25e056 Compare March 2, 2024 04:13
@stevenharman
Copy link
Collaborator Author

👋 Hello @fgrehm, and thank you for letter_opener_web. I know being an OSS maintainer is a largely thankless job, and we're often focused elsewhere. As we actively use this tool at my day job, I'd be happy to lend a hand in managing PRs and such? And even cutting a new release on RubyGems, if you're looking for help there.

Thank you, again!

@fgrehm
Copy link
Owner

fgrehm commented May 10, 2024

Hey @stevenharman! Sorry for the delay and sure, I could use some help here!
I'll try to cycle back to this next week 🤞

Moved dev/test dependencies into proper Bundler groups. I also added
binstubs for rspec and rubocop - this ensures we're running the right
versions of those tools locally.
The default constraint on segments does not allow dot (.) characters,
so requests for attachments with a dot in the file name wouldn't find a
route, resulting in a 404 out of the Rails router.
@stevenharman stevenharman force-pushed the allow_dot_in_attachement_name branch from a25e056 to af99799 Compare May 13, 2024 22:53
@stevenharman stevenharman merged commit af99799 into fgrehm:master May 13, 2024
8 checks passed
@stevenharman stevenharman deleted the allow_dot_in_attachement_name branch May 13, 2024 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants