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

Fix issue with content-disposition existing with no filename when downloading #1323

Merged
merged 2 commits into from
Feb 24, 2014
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/carrierwave/uploader/download.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def file

def filename_from_header
if file.meta.include? 'content-disposition'
match = file.meta['content-disposition'].match(/filename=(\"?)(.+)\1/)
return match[2] unless match.nil?
match = file.meta['content-disposition'].match(/filename="?([^"]+)/)
return match[ 1 ] if !match.nil? && !match[ 1 ].empty?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good, but without further review I'm not sure why it's better to return nil if the match is empty.

end
end

Expand Down