Don't URL-encode cookies.

This commit is contained in:
Markus Reiter 2019-05-31 22:00:48 +02:00
parent eec2928754
commit 0a0672fade
2 changed files with 4 additions and 7 deletions

View File

@ -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)

View File

@ -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