From ee04f8fef3e074d81dd1fd46452f2930a6b0b166 Mon Sep 17 00:00:00 2001 From: Nick/Nelson Date: Wed, 21 Mar 2018 00:34:24 +0000 Subject: [PATCH] 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. --- vsco-dl.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vsco-dl.rb b/vsco-dl.rb index 840a3b6..7751048 100644 --- a/vsco-dl.rb +++ b/vsco-dl.rb @@ -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