A platform for community discussion. Free, open, simple.
FIX: do not treat ignore_redirects domains as blacklisted
Arpit Jalanfadcd36f92f2
diff --git a/lib/oneboxer.rb b/lib/oneboxer.rbindex a0f48d43b33..fee360a87f9 100644--- a/lib/oneboxer.rb+++ b/lib/oneboxer.rb@@ -248,13 +248,15 @@ module Oneboxerendend+ def self.blacklisted_domains+ SiteSetting.onebox_domains_blacklist.split("|")+ end+def self.external_onebox(url)Rails.cache.fetch(onebox_cache_key(url), expires_in: 1.day) do- ignored = SiteSetting.onebox_domains_blacklist.split("|")-- fd = FinalDestination.new(url, ignore_redirects: ignore_redirects, ignore_hostnames: ignored, force_get_hosts: force_get_hosts)+ fd = FinalDestination.new(url, ignore_redirects: ignore_redirects, ignore_hostnames: blacklisted_domains, force_get_hosts: force_get_hosts)uri = fd.resolve- return blank_onebox if uri.blank? || ignored.map { |hostname| uri.hostname.match?(hostname) }.any?+ return blank_onebox if uri.blank? || blacklisted_domains.map { |hostname| uri.hostname.match?(hostname) }.any?options = {cache: {},diff --git a/spec/components/oneboxer_spec.rb b/spec/components/oneboxer_spec.rbindex 79520340ab6..b3524267ed0 100644--- a/spec/components/oneboxer_spec.rb+++ b/spec/components/oneboxer_spec.rb@@ -116,4 +116,12 @@ describe Oneboxer doexpect(Oneboxer.external_onebox('https://discourse.org/')[:onebox]).to be_emptyend+ it "does not consider ignore_redirects domains as blacklisted" do+ url = 'https://store.steampowered.com/app/271590/Grand_Theft_Auto_V/'+ stub_request(:head, url).to_return(status: 200, body: "", headers: {})+ stub_request(:get, url).to_return(status: 200, body: "", headers: {})++ expect(Oneboxer.external_onebox(url)[:onebox]).to be_present+ end+end