diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 924c17f117..467959f213 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -415,10 +415,7 @@ class CurlDownloadStrategy < AbstractFileDownloadStrategy def _curl_args args = [] - if meta.key?(:cookies) - escape_cookie = ->(cookie) { URI.encode_www_form([cookie]) } - args += ["-b", meta.fetch(:cookies).map(&escape_cookie).join(";")] - end + args += ["-b", meta.fetch(:cookies).map { |k, v| "#{k}=#{v}" }.join(";")] if meta.key?(:cookies) args += ["-e", meta.fetch(:referer)] if meta.key?(:referer) diff --git a/Library/Homebrew/test/download_strategies_spec.rb b/Library/Homebrew/test/download_strategies_spec.rb index 615daa05f9..e8b456d226 100644 --- a/Library/Homebrew/test/download_strategies_spec.rb +++ b/Library/Homebrew/test/download_strategies_spec.rb @@ -215,15 +215,15 @@ describe CurlDownloadStrategy do let(:specs) { { cookies: { - coo: "kie", + coo: "k/e", mon: "ster", }, } } - it "adds the appropriate curl args" do + it "adds the appropriate curl args and does not URL-encode the cookies" do expect(subject).to receive(:system_command!) { |*, args:, **| - expect(args.each_cons(2)).to include(["-b", "coo=kie;mon=ster"]) + expect(args.each_cons(2)).to include(["-b", "coo=k/e;mon=ster"]) } subject.fetch