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

Handling of \n character in MIME::Types.type_for #177

Closed
ooooooo-q opened this issue Aug 22, 2023 · 1 comment · Fixed by #178
Closed

Handling of \n character in MIME::Types.type_for #177

ooooooo-q opened this issue Aug 22, 2023 · 1 comment · Fixed by #178
Assignees
Labels

Comments

@ooooooo-q
Copy link

I have found a pattern inMIME::Types.type_for where the decision is wrong if there is a \n character.

 bundle exec irb
irb(main):001:0> require 'mime-types'
=> true # mime-types (3.5.0)

irb(main):002:0> MIME::Types.type_for("test.pdf")
=> [#<MIME::Type: application/pdf>]

irb(main):003:0> MIME::Types.type_for("test.txt\n.pdf")
=> [#<MIME::Type: text/plain>]  # <- detected as text, not pdf

irb(main):004:0> MIME::Types.type_for("test.txt\r.pdf")
=> [#<MIME::Type: application/pdf>]
irb(main):005:0> MIME::Types.type_for("test.txt\0.pdf")
=> [#<MIME::Type: application/pdf>]
@halostatue halostatue self-assigned this Aug 22, 2023
@halostatue halostatue added the Bug label Aug 22, 2023
halostatue added a commit that referenced this issue Aug 22, 2023
Resolves #177.

Better handle possible line-termination strings (legal in Unix
filenames) such as `\n` in `MIME::Types.type_for`. Reported by
ooooooo-q.
halostatue added a commit that referenced this issue Aug 22, 2023
Resolves #177.

Better handle possible line-termination strings (legal in Unix
filenames) such as `\n` in `MIME::Types.type_for`. Reported by
ooooooo-q.
@halostatue
Copy link
Member

Thank you for the bug report!

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 a pull request may close this issue.

2 participants