Bug: Valid URLs may not survive display formatting

Type 'ooc https://en.wikipedia.org/wiki/Downsizing_(film)'

The clickable link becomes ‘https://en.wikipedia.org/wiki/Downsizing_’.

1 Like

Welcome to the forum, @Lochiel! :partying_face:

Nice catch. I will have a fix for it in next release.

/Accipiter

Phew. That is an annoying URL.

If I simply include parenthesis, it will break the links for players putting URLs inside parenthesis:

:shows Lochiel a picture. (https://wolfery.com/paw.png)

Instead, I would need to determine if that closing parenthesis is part of the URL or not, by checking where I have a matching starting parenthesis.

Ah, well, I put it in my bugs to fix later list.

/Accipiter

Well, there’s no guarantee there won’t be a close parenthesis in a URL without an open one or vice versa. And the user might still put that in parenthesis. Honestly, requiring a space on either side of the URL isn’t unusual at all to ensure proper embedding.

Generally you have to parse the surrounding punctuation first. If there’s a “(” just before the http, you can look for the last “)” in the contiguous text following the http and throw that away before calling the rest of it the URL. If someone happens to enter a malformed “(https://site/die_hard_(film)” when the actual URL is “https://site/die_hard_(film” (without a right paren), well, they get what they deserve.

Yeah, something like Daring Fireball: An Improved Liberal, Accurate Regex Pattern for Matching URLs maybe.

This is perfect!

Since I use regex, this would solve the most common problem.

Yes, this assumes that there are matching parenthesis inside the URL. But, you have to make some assumptions like that; it is impossible to do anything else.

True. But that would likely require a more refined sort of state engine, instead of the simpler regex parsing currently used. I think that @Raeth’s link, where you just validate matching parenthesis within the url is good enough. It solves Wikipedia links :slight_smile:

The new regex will be included in next release.

/Accipiter