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

spoofed_media_type error when the file name is broken #131

Open
sobrinho opened this issue Dec 5, 2023 · 1 comment
Open

spoofed_media_type error when the file name is broken #131

sobrinho opened this issue Dec 5, 2023 · 1 comment

Comments

@sobrinho
Copy link

sobrinho commented Dec 5, 2023

Describe the bug
Using a file named original. breaks the spoof validation.

To Reproduce
Attach a file on a URL that returns the content type header as image/png but the file name is broken such as original..

Expected behavior
Ignore the spoof validation against file extension.

Screenshots
N/A

Desktop (please complete the following information):
N/A

Smartphone (please complete the following information):
N/A

Additional context
Probably broken because of:

File.extname("original.")
#=> "."
@sobrinho
Copy link
Author

sobrinho commented Dec 5, 2023

Our monkey patch so far:

Paperclip::MediaTypeSpoofDetector.class_eval do
  def has_extension?
    filename_extension.present?
  end
end

Trying to validate if that's okay.

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

No branches or pull requests

1 participant