Quoting across discourse instances with links getting process as local links

Before I get into this, I want to mention that I was going to try duplicating this on try.discourse, but it appears to be offline. Since I didn’t want to pollute things experimenting here, I’m just presenting what I found at WTDWTF.

Ok, basic description. Generally when quoting a post by using a link, you get pretty reliable results. However, when I have been trying to quote posts from here over at WTDWTF, I’ve been getting 1 of 2 results:

  1. The topic ID and post number are parsed from the link, and then the relevant post from WTDWTF is wuoted instead of the post from here. [Example]
  2. The link is left bare. Base on experimentation, it appears that this is because the corresponding topic at WTDWTF is restricted access, or the corresponding post does not exist. [Example]

Let’s see what happens here when I try to link to the corresponding bug report at WTDWTF:

3 Likes

Looks like the link is bare because no corresponding topic exists here. Let’s try with a link to an older WTDWTF topic:

http://what.thedailywtf.com/t/why-use-sql-when-you-can-do-it-by-hand/26672/5?u=abarker

http://what.thedailywtf.com/t/why-use-sql-when-you-can-do-it-by-hand/26672/5?u=abarker

Well yeah because anons can’t see bug topics there, right? Hmm, no, I can get to that topic in incognito mode.

It seems that if the parser sees anything that resembles a discourse link, it just assumes that it is for the local instance. It just grabs the topic ID and post number and ignores the rest. For example, this won’t resolve at all: https://chicken/t/pox/26672/2. But if you put it in a post for onebox quoting:

https://chicken/t/pox/26672/2

4 Likes

I see that is much clearer probably a regression. @eviltrout you should add that to your list.

Potentially Definitely related to the change I just made?

https://github.com/discourse/discourse/pull/3387/files#diff-5706007ce16fc2a1eb8526567e15dc0bR13

https://github.com/discourse/discourse/blob/3681674ec4dfc01ace08276c224faad5dd2befe8/lib/onebox/engine/discourse_local_onebox.rb#L13-L30

A fix might be to replace true with super - in that case, it’ll check for Discourse.base_url as well.

Or stick return false unless super at the start of the method.


Here’s a fix:

https://github.com/discourse/discourse/pull/3395

6 Likes