Skip to content
Merged
Changes from all commits
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
3 changes: 3 additions & 0 deletions Library/Homebrew/download_strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ def resolve_url_basename_time_file_size(url)
filename = URI.decode_www_form_component(encoded_filename).encode(encoding) if encoding && encoded_filename
end

# Servers may include '/' in their Content-Disposition filename header. Take only the basename of this, because:
# - Unpacking code assumes this is a single file - not something living in a subdirectory.
# - Directory traversal attacks are possible without limiting this to just the basename.
(filename || content_disposition.filename).rpartition("/")[-1]
end

Expand Down