Oneboxing URLs with two dashes

Ok, here’s a weird bug. When an URL contains --, the markdown converts it do –

For example, this URL: cs--preview.khanacademy.org

https://cs–preview.khanacademy.org

If I explicitly insert a link, it works, even though it is rendered incorectly:
[https://cs--preview.khanacademy.org](https://cs--preview.khanacademy.org)
https://cs–preview.khanacademy.org

PS: Hm, linkifying seems to be disabled here on meta, but hopefully the second example makes things clear.

Having two dashes in the URL is quite unusual. Do you need to do that? Why doesn’t a single dash suffice?

Well, I do not know, but I do not control how the URL looks. :slight_smile: I’d say if it is a valid URL, Discourse should handle it correctly, no?

2 Likes

I do think it is a minor bug in linkify / prettify interaction, @Vitaly is this an edge case we should report?

@danekhollas a workaround is to do <https://cs--preview.khanacademy.org> https://cs--preview.khanacademy.org which bypasses all magic.

4 Likes

That works but also prevents oneboxing.

There is an edge case here where we should onebox

<https://example.com>

On a line by itself

<> though is already the escape hatch from inline onebox so this would give it double meaning, it is edge case on top of edge case. Tricky problem, not sure there is trivial solution here. prettify though should ideally apply after linkify not before it, we can fix that.

I guess… the escape from one boxing is also to add a space in front of the URL. I have run into other cases like this on BBS so it is a real problem. I had to use HTML entity escaping to get around it which is even worse.

Sorry, I mean for example: https://unsplash.com/collections/411759/awesome-pictures will become https://unsplash.com/collections/411759/awesome-pictures so the escape hatch is: <https://unsplash.com/collections/411759/awesome-pictures> if you need it or a raw link without inline onebox.

So that means we turn <> into

  1. opt-in to onebox by force
  2. opt-out of inline onebox by force

It kind of has a double meaning, since it is mega ninja territory I guess we can live with it.

I am ok to make this change I guess.

This also raises the question of how do we “force opt-in” an inline onebox which I guess mean punycode url for now.

I am only referring to full size one boxes

See Onebox all the links! - meta - Boing Boing BBS

1 Like

I guess, “two-dashes” issue was solved in linkifier linkify-it/CHANGELOG.md at master · markdown-it/linkify-it · GitHub, and auto-propagated to markdown-it.

So, fix was landed to discourse after dependencies uprgade. Proof:

test http://cs--preview.khanacademy.org test

I think, this can be marked as solved. No more <...> scopes required for this kind of links.

3 Likes