mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: allow HTTP <-> HTTPS redirections when downloading images
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -53,6 +53,8 @@ gem 'fast_xs'
|
|||||||
|
|
||||||
gem 'fast_xor'
|
gem 'fast_xor'
|
||||||
|
|
||||||
|
gem 'open_uri_redirections'
|
||||||
|
|
||||||
# while we sort out https://github.com/sdsykes/fastimage/pull/46
|
# while we sort out https://github.com/sdsykes/fastimage/pull/46
|
||||||
gem 'fastimage_discourse', require: 'fastimage'
|
gem 'fastimage_discourse', require: 'fastimage'
|
||||||
gem 'aws-sdk', require: false
|
gem 'aws-sdk', require: false
|
||||||
|
|||||||
@@ -214,6 +214,7 @@ GEM
|
|||||||
multi_json (~> 1.11)
|
multi_json (~> 1.11)
|
||||||
mustache
|
mustache
|
||||||
nokogiri (~> 1.6.6)
|
nokogiri (~> 1.6.6)
|
||||||
|
open_uri_redirections (0.2.1)
|
||||||
openid-redis-store (0.0.2)
|
openid-redis-store (0.0.2)
|
||||||
redis
|
redis
|
||||||
ruby-openid
|
ruby-openid
|
||||||
@@ -443,6 +444,7 @@ DEPENDENCIES
|
|||||||
omniauth-openid
|
omniauth-openid
|
||||||
omniauth-twitter
|
omniauth-twitter
|
||||||
onebox
|
onebox
|
||||||
|
open_uri_redirections
|
||||||
openid-redis-store
|
openid-redis-store
|
||||||
pg
|
pg
|
||||||
pry-nav
|
pry-nav
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class FileHelper
|
|||||||
tmp = Tempfile.new([tmp_file_name, extension])
|
tmp = Tempfile.new([tmp_file_name, extension])
|
||||||
|
|
||||||
File.open(tmp.path, "wb") do |f|
|
File.open(tmp.path, "wb") do |f|
|
||||||
downloaded = uri.open("rb", read_timeout: 5, redirect: follow_redirect)
|
downloaded = uri.open("rb", read_timeout: 5, redirect: follow_redirect, allow_redirections: :all)
|
||||||
while f.size <= max_file_size && data = downloaded.read(512.kilobytes)
|
while f.size <= max_file_size && data = downloaded.read(512.kilobytes)
|
||||||
f.write(data)
|
f.write(data)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user