Mattermost Peer-to-Peer Forum

Auto hyperlink drops trailing curly brace



A URL in a post that ends with curly brace is replaced with an autolink that has dropped the curly brace.

Steps to reproduce

Mattermost 5.6.2 or 5.7.0, any client
Write the following post:

Let's try http://example/result?things={stuff}

Expected behavior

The URL is replaced by a hyperlink http://example/result?things={stuff} including the closing curly brace

Observed behavior

The URL is replaced by a hyperlink http://example/result?things={stuff}, so the curly brace is plain text outside the hyperlink


I tried to reproduce the issue in autolink_test.go in the mattermost server project, but it does the right thing for this example (the result of parseAutolink did include the brace).


Actually I guess this is a problem with the rendering in the webapp, not the server, right? Maybe this comes from a bug in marked.js?


Hey @gubbins.

Interesting find. I would’ve said that it’s just a bug in marked.js, but it also occurs with the custom autolinking we’ve added to commonmark.js in the mobile app as well. I’m actually surprised the server’s Markdown parser handles it correctly, but I’m pretty sure that I just translated that code from GitHub’s Markdown parser instead of trying to write a completely custom version like the apps use.

I spent a bit of time comparing the code used on the server with our custom marked and commonmark versions, and it looks like the difference is that the apps treat curly brackets, as well as some other characters, as punctuation that should be trimmed from the end of the link, while the server does not. Fixing that should actually be fairly easy in that case, since I expected it to be caused by something more complicated. Great catch that the server handles it correctly or else we might not have noticed that.

I’ve filed MM-13837 to look into this further. Also, since you were comfortable digging around in the markdown parser on the server, I can gladly point you into the right direction if you’d like to help out by fixing it on the web and mobile apps. :slightly_smiling_face:


Thanks @hmhealey. I have almost zero JavaScript knowledge right now so I doubt I will be much use on the webapp side but maybe I will take a look one weekend…