mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
download_strategy: more robust filename content encoding handling.
Fixes #5713.
This commit is contained in:
parent
d3a1554805
commit
0c44498581
@ -371,14 +371,18 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy
|
||||
parse_content_disposition = lambda do |line|
|
||||
next unless content_disposition = content_disposition_parser.parse(line, true)
|
||||
|
||||
filename = nil
|
||||
|
||||
if filename_with_encoding = content_disposition.parameters["filename*"]
|
||||
encoding, encoded_filename = filename_with_encoding.split("''", 2)
|
||||
URI.decode_www_form_component(encoded_filename).encode(encoding)
|
||||
else
|
||||
content_disposition.filename
|
||||
if encoding && encoded_filename
|
||||
filename = URI.decode_www_form_component(encoded_filename).encode(encoding)
|
||||
end
|
||||
end
|
||||
|
||||
filename || content_disposition.filename
|
||||
end
|
||||
|
||||
filenames = lines.map(&parse_content_disposition).compact
|
||||
|
||||
time =
|
||||
|
Loading…
x
Reference in New Issue
Block a user