Fix weird https redirection downgrade bug

For some reason this endpoint occasionally sends a 302 redirect to an http image instead of https. >:(
Ideally this should be reverted back to using https at some point, but I can't reproduce this in any
browser, so I have no idea what exactly is causing it. Sometimes changing the referer works for specific
images, other times it doesn't. This isn't the most secure, but it should be the most reliable. Hopefully
whoever is mitm-ing you isn't concerned with what vsco profiles you're downloading.
This commit is contained in:
Nick/Nelson 2018-03-21 00:34:24 +00:00
parent 66a657baa2
commit ee04f8fef3
No known key found for this signature in database
GPG Key ID: 01365471E7AAA465
1 changed files with 3 additions and 1 deletions

View File

@ -79,7 +79,9 @@ images.each_with_index do |r, i|
image_url = r['is_video'] ? r['video_url'] : r['responsive_url']
image_path = "#{file_path}#{File.extname image_url}"
if options[:overwrite] or not File.exist? image_path
open "https://#{image_url}" do |f|
# opening these with https was oddly buggy and would constantly
# try to redirect downgrade to http no matter what I did
open "http://#{image_url}" do |f|
File.open image_path, 'wb' do |file|
file.write f.read
end