Onebox 重定向阻止链接到仅限登录的内容

Onebox follows redirects, which is usually a good thing, I guess.

This becomes a problem, however, when you share a link to a page requiring sign-in that simply redirects to a sign-in page when an anonymous user visits it.

For example, if I want to share my top secret project hosted at https://dgit.cs.uni-saarland.de/fefrei/my-top-secret-project/ in the internal category of our Discourse instance, this is what I get by default:

Note that all links in the Onebox go to https://dgit.cs.uni-saarland.de/users/sign_in, which is not helpful.

Of course, as a post author, I can prevent that by using any alternative markup that prevents the Onebox (which can’t show relevant content anyways); but if some other user does this and doesn’t notice, it’s pretty hard to retrieve the actual link.
As staff, I can edit the post to get the raw markup, but as a non-staff user, I think the only feasible workaround is to remember the magic /raw/ URL scheme.

Why does the Onebox link to the final location, not the original URL? Can we do something to improve this?

2 个赞

Why wouldn’t it link to the final location?

I typed https://dgit.cs.uni-saarland.de/fefrei/my-top-secret-project/, why should it link somewhere else?

When I’m redirected to the sign in page, this is fine, because I’m in a session – I can actually log in, and will be redirected back to the target URL.
When Discourse follows the redirect, forgets the original URL and just outputs the sign in URL, the reader has no (easy) way to get to the URL the author linked to.

Well, the workaround is to enter the link with angle brackets. It’s normal and expected to follow link redirects to the final destination.

I know that’s the current behavior, and already mentioned the workaround above:

I stumbled about this because another user fell for this trap, and I had to fish the actual link out of the raw view.

I’m not saying that this is terribad and needs to be fixed now or else; I’m just reporting that I find it sad that a user who simply pasted a link into his post got a Onebox that obfuscates the link in a way that makes it impossible for the average user to understand where to go. (There’s a reason I posted this in feature.)

1 个赞

我今天遇到了这种行为,并支持对用户体验进行改进。

如果你希望与你分享链接的人经过身份验证或能够访问目标网站进行身份验证,那么你不希望链接到最终位置的情况就会出现。

此外,从外观上看,我在另一个社区发布了一个指向 Discourse 线程的链接,但该链接被修改为指向登录页面。人们问我是否发布了错误的链接,因为故意链接到登录页面是很奇怪的。归根结底,这改变了用户原本想要发布的内容。

变通方法虽然有效,但并不理想。我们应该采用更智能的默认设置,尤其是如果我们希望避免给发布者和点击链接的用户带来糟糕的用户体验。

3 个赞

我想不出除了通过字符串匹配硬编码处理“登录”之外的其他方法,而我真的非常不喜欢这种方案,因为它会极其脆弱。

为什么你需要这样的功能?

如果这造成了困惑,我很抱歉,也许我最初的请求表达得不够清楚。让我来澄清一下:

假设用户链接到 https://example.org/a,但该链接在未登录时会重定向到 https://example.org/login。当前的行为是:

  1. Discourse 请求 https://example.org/a 并跟随重定向。
  2. Discourse 请求 https://example.org/login 并获取标题、图片等信息。
  3. Discourse 显示一个 Onebox,展示从 https://example.org/login 获取的信息,并且链接指向 https://example.org/login。生成的 Onebox 中没有任何地方链接到 https://example.org/a

只有加粗的部分是我认为有问题的。是的,完全可以跟随链接并从那里获取信息,但 Onebox 应该始终链接到我输入的原始 URL。

这并不是关于 Onebox 显示登录页面的信息(它还能显示什么?),而是关于 Onebox 的生成完全掩盖了原始链接的目标。

如果实现了这一点,我原始帖子中的 Onebox 看起来仍然会完全一样,但会链接到 https://dgit.cs.uni-saarland.de/fefrei/my-top-secret-project/

这样解释是否更清楚了一些?:slight_smile:

3 个赞

也不是,毕竟现在互联网上大多数“链接”都是某种形式的重定向?

但这有什么错呢?即使用户点击重定向链接,它也能正常工作,就像该链接没有被单框显示一样……

1 个赞

是的。

一个链接指向你实际链接的内容,而不是重定向后的地址,这样是合理的。这能解决该问题,且据我所知不会破坏任何现有功能。

如果所有内容都发生重定向,那么保留原始链接就显得更加合理了。

3 个赞

我不同意——你想知道的是最终的目的地,而不是你点击了一个通用的链接缩短服务。我在这里的观点完全相反。

显示

嘿,你要点击 link.is/ghwk4fe3

比显示

嘿,你要点击 example.com/funny-article

要没用得多。

1 个赞

但我们这里讨论的是 Oneboxes。对于非 Oneboxes,你本来就不会这样做。
此外,事实上,我并不反对显示最终 URL。但在需要登录的场景中,不链接到原始 URL 会导致链接失效 :frowning:

5 个赞

我完全同意你的观点,但你需要用一个登录页面的示例亲自试一试。Meta 中是否有关于私有分类的示例?假设我们有一个,而我在回复中贴出了链接。由于“一栏预览”(one box)的工作方式,你将永远无法得知该链接原本指向何处,也无法访问它。

我并不反对让“一栏预览”显示最终页面的内容,但如果保留原始 URL 的功能被破坏,那么在这种场景下,重定向将无法按预期工作。此外,原始链接中的任何归属标签也会因此失效。

3 个赞