mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 14:03:22 +08:00
FIX: do not treat ignore_redirects domains as blacklisted
This fix prevents domains present in `ignore_redirects` to be treated as blacklisted domains and makes sure that onboxing happens for those domains. Issue reported here: https://meta.discourse.org/t/steam-store-oneboxing-no-longer-works/97266
This commit is contained in:
parent
ce6a0a5e9e
commit
fadcd36f92
|
@ -248,13 +248,15 @@ module Oneboxer
|
|||
end
|
||||
end
|
||||
|
||||
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: {},
|
||||
|
|
|
@ -116,4 +116,12 @@ describe Oneboxer do
|
|||
expect(Oneboxer.external_onebox('https://discourse.org/')[:onebox]).to be_empty
|
||||
end
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user