Workaround for 'undefined method closed?' error caused by ssrf_filter 1.1

Closes #2628
This commit is contained in:
Mitsuhiro Shibuya 2022-11-06 18:47:03 +09:00
parent 9d03bcd3c1
commit 65bf0d9475
No known key found for this signature in database
GPG Key ID: 76087F03B4FB52E7
2 changed files with 13 additions and 1 deletions

View File

@ -35,7 +35,9 @@ module CarrierWave
request = req
end
else
response = SsrfFilter.get(uri, headers: headers, request_proc: ->(req) { request = req })
response = SsrfFilter.get(uri, headers: headers, request_proc: ->(req) { request = req }) do |res|
res.body # ensure to read body
end
end
response.uri = request.uri
response.value

View File

@ -156,6 +156,16 @@ describe CarrierWave::Downloader::Base do
end
end
context 'when actually downloading a file' do
let(:uri) { 'https://raw.githubusercontent.com/carrierwaveuploader/carrierwave/master/spec/fixtures/test.jpg' }
before { WebMock.disable! }
after { WebMock.enable! }
it 'retrieves the body successfully' do
expect(subject.download(uri).file.read).to eq 'this is stuff'
end
end
describe '#process_uri' do
it "converts a URL with internationalized domain name to Punycode URI" do
uri = "http://ドメイン名例.jp/#{CGI.escape(filename)}"