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

curl: handle multiple Content-Type headers #18596

Merged
merged 1 commit into from
Oct 20, 2024
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
8 changes: 7 additions & 1 deletion Library/Homebrew/utils/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,15 @@

if status.success?
open_args = {}
content_type = headers["content-type"]

Check warning on line 470 in Library/Homebrew/utils/curl.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/utils/curl.rb#L470

Added line #L470 was not covered by tests

# Use the last `Content-Type` header if there is more than one instance
# in the response
content_type = content_type.last if content_type.is_a?(Array)

# Try to get encoding from Content-Type header
# TODO: add guessing encoding by <meta http-equiv="Content-Type" ...> tag
if (content_type = headers["content-type"]) &&
if content_type &&
(match = content_type.match(/;\s*charset\s*=\s*([^\s]+)/)) &&
(charset = match[1])
begin
Expand Down
Loading