3.0.4 (稳定版) 中的嵌入已损坏

我怀疑这个更改

破坏了我网站上的嵌入方式。有人能指出具体是哪里被更改了吗?

我使用 Discourse 为我的博客帖子创建主题(作为评论系统)。我的网站分为两部分,用于两种语言,因此我使用两个主机将英语(/blog/somepost)和德语(/de/blog/somepost)帖子过滤到不同的论坛类别中。

自从我的 Discourse 更新后,来自网站德语部分的帖子就无法再嵌入了。我推测这与上面的补丁有关。

非常感谢您在解决此问题上的任何帮助。

2 个赞

另一方面,这可能是这个问题:

我确实遇到了那些 DOMExceptions。同样,非常感谢任何帮助!

1 个赞

是的,我会查看您论坛和嵌入式网站的安全策略和设置。截图看起来还可以。您使用的是什么脚本?您其他的嵌入设置呢?您最近有做过什么更改吗?

我的论坛每天多次使用此嵌入式发帖功能,目前运行良好,所以我知道它没有坏。我们正在使用最新的测试版,并且是托管的,所以我对配置很有信心。

1 个赞

嘿,谢谢你帮忙!

我无法控制任何安全策略,因为这两个网站都由托管服务提供商托管。我很难相信是他们导致了这个问题。但我会和我的 Discourse 托管商一起调查。

我在博客上使用了这个脚本(它是一个名为 Hugo 的静态站点引擎):

<script type="text/javascript">
  DiscourseEmbed = { discourseUrl: 'https://forum.fab.industries/',
                     discourseEmbedUrl: '{{ .Permalink }}' };

  (function() {
    var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
    d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
  })();
</script>

自从几个月前我第一次集成它以来,我没有对它做过任何更改。

确实更改的是我在论坛主题中添加的一些小的自定义 CSS。我今天会撤销它,看看是否能解决问题。

好的。回滚 CSS 无济于事。反正这也是个渺茫的希望。

我现在也确认了嵌入式功能总体上已损坏。博客的英文版也停止工作了。“正在加载讨论…”新页面卡在这里。

我现在很确定这是因为我的提供商将我的论坛更新到了 3.0.4,但我不知道他们是从哪个版本更新的。所以我仍然怀疑是这个补丁出了问题:

我猜浏览器抛出这些与 DOM 相关的错误并非偶然:

在管理员设置中关闭 CSP 似乎也无法解决问题。

So main has this

TopicEmbed.import_remote(@embed_url, user: User.find_by(username_lower: username.downcase))

and stable has this

TopicEmbed.import_remote(user, @embed_url)

Note the order of the parameters.

Now the backport of the security patch changed the function signature on stable to the new parameter order,so

def self.import_remote(import_user, url, opts = nil)

became

def self.import_remote(url, opts = nil)

and now the url parameter receives a User object.

Changing the function call resolves the issue

diff --git a/lib/topic_retriever.rb b/lib/topic_retriever.rb
index b798df6cd7..6186ce5868 100644
--- a/lib/topic_retriever.rb
+++ b/lib/topic_retriever.rb
@@ -50,6 +50,6 @@ class TopicRetriever
     user = User.where(username_lower: username.downcase).first
     return if user.blank?

-    TopicEmbed.import_remote(user, @embed_url)
+    TopicEmbed.import_remote(@embed_url, user: user)
   end
 end

@blake

8 个赞

我提交了一个 PR 来修复此问题 FIX broken topic embedding because of incomplete security patch (#22088) by communiteq · Pull Request #22184 · discourse/discourse · GitHub

9 个赞

感谢 @RGJ 的修复,该拉取请求现已合并。

4 个赞