Merge pull request #5018 from discourse/wekbit-embedded-referer

FIX: First load of embed comments would always fail on WebKit
This commit is contained in:
Guo Xiang Tan 2017-08-04 14:12:26 +09:00 committed by GitHub
commit 40fc6c429a
2 changed files with 7 additions and 0 deletions

View File

@ -32,6 +32,9 @@ class EmbeddableHost < ActiveRecord::Base
end
def self.url_allowed?(url)
# Work around IFRAME reload on WebKit where the referer will be set to the Forum URL
return true if url&.starts_with?(Discourse.base_url)
uri = URI(URI.encode(url)) rescue nil
uri.present? && record_for_url(uri).present?
end

View File

@ -78,6 +78,10 @@ describe EmbeddableHost do
expect(EmbeddableHost.url_allowed?('http://eviltrout.com')).to eq(true)
expect(EmbeddableHost.url_allowed?('http://discourse.org')).to eq(true)
end
it 'always allow forum own URL' do
expect(EmbeddableHost.url_allowed?(Discourse.base_url)).to eq(true)
end
end
describe "path_whitelist" do