A platform for community discussion. Free, open, simple.
FIX: Request html when fetching inline onebox data (#24674)
Jarek Radosz74011232e9bc
diff --git a/lib/final_destination.rb b/lib/final_destination.rbindex 35aac08e3b0..66c2ff4cf23 100644--- a/lib/final_destination.rb+++ b/lib/final_destination.rb@@ -86,6 +86,7 @@ class FinalDestinationend)@stop_at_blocked_pages = @opts[:stop_at_blocked_pages]+ @extra_headers = @opts[:headers]enddef self.connection_timeout@@ -120,6 +121,7 @@ class FinalDestination"Host" => @uri.hostname + (@include_port_in_host_header ? ":#{@uri.port}" : ""),}+ result.merge!(@extra_headers) if @extra_headersresult["Cookie"] = @cookie if @cookieresultdiff --git a/lib/retrieve_title.rb b/lib/retrieve_title.rbindex d75cae8f5ac..c00e27ed523 100644--- a/lib/retrieve_title.rb+++ b/lib/retrieve_title.rb@@ -78,6 +78,9 @@ module RetrieveTitlestop_at_blocked_pages: true,max_redirects: max_redirects,initial_https_redirect_ignore_limit: initial_https_redirect_ignore_limit,+ headers: {+ Accept: "text/html,*/*",+ },)current = nildiff --git a/spec/models/topic_link_spec.rb b/spec/models/topic_link_spec.rbindex ca80227ff3d..773d34c8009 100644--- a/spec/models/topic_link_spec.rb+++ b/spec/models/topic_link_spec.rb@@ -1,18 +1,13 @@# frozen_string_literal: trueRSpec.describe TopicLink do- it { is_expected.to validate_presence_of :url }-- def test_uri- URI.parse(Discourse.base_url)- end-+ let(:test_uri) { URI.parse(Discourse.base_url) }fab!(:topic) { Fabricate(:topic, title: "unique topic name") }-fab!(:user) { topic.user }-fab!(:post)+ it { is_expected.to validate_presence_of :url }+it "can't link to the same topic" doftl = TopicLink.new(url: "/t/#{topic.id}", topic_id: topic.id, link_topic_id: topic.id)expect(ftl.valid?).to eq(false)@@ -25,7 +20,7 @@ RSpec.describe TopicLink do# prepare a title for one of the linksstub_request(:get, non_png).with(headers: {- "Accept" => "*/*",+ "Accept" => "text/html,*/*","Accept-Encoding" => "gzip","Host" => "b.com",},@@ -273,6 +268,7 @@ RSpec.describe TopicLink dolet(:post) doFabricate(:post, topic: topic, user: user, raw: "<a href='/faq'>faq link here</a>")end+before { TopicLink.extract_from(post) }it "does not extract a link" do